casacore
|
#include <JsonParser.h>
Static Public Member Functions | |
static JsonKVMap | parse (const String &command) |
Parse the command in the given string and return the resulting map. More... | |
static JsonKVMap | parseFile (const String &fileName) |
Parse the given file and return the resulting map. More... | |
static int | input (char *buf, int max_size) |
Give the next chunk of input for the scanner. More... | |
static int & | position () |
Give the current position (for read or update). More... | |
static String | removeEscapes (const String &in) |
Remove all possible escape characters and convert as needed (including \uxxxx ). More... | |
static void | setMap (JsonKVMap *map) |
Let the parser set the final KeyValueMap. More... | |
Static Private Attributes | |
static int | theirPosition |
static const char * | theirCommand |
static JsonKVMap * | theirJsonMap |
Class for parsing Json-style key:value lines.
Public interface
JsonParser is a class for parsing JSON files. Its function 'parse' is the main function to do so. It can handle any JSON file (not only those generated by JsonOut). It supports (i.e., strips) possible comments in C, C++ and Python style. It also supports complex numbers (structs with fields "r" and "i"). Escaped characters in a string value are translated into their ASCII counterparts.
The result of the parser is a JsonKVMap object containing all fields and values (scalars, arrays and structs, possibly nested in any way). The values in the map are stored as JsonValue objects, which have functions to get the value with the proper type.
The following example is the opposite of the one given for class JsonOut.
JSON is a commonly used interchange format. However, commonly available parsers do not support data type Complex. Also, comments are often not supported (alas standard Json does not allow comments).
Definition at line 93 of file JsonParser.h.
|
static |
Give the next chunk of input for the scanner.
Parse the command in the given string and return the resulting map.
Parse the given file and return the resulting map.
Comments are ignored; they can be indicated by // or # till eol or be enclosed in / * and * /.
|
inlinestatic |
Give the current position (for read or update).
Definition at line 108 of file JsonParser.h.
References theirPosition.
Remove all possible escape characters and convert as needed (including \uxxxx
).
|
inlinestatic |
Let the parser set the final KeyValueMap.
Definition at line 115 of file JsonParser.h.
References theirJsonMap.
|
staticprivate |
Definition at line 120 of file JsonParser.h.
|
staticprivate |
Definition at line 121 of file JsonParser.h.
Referenced by setMap().
|
staticprivate |
Definition at line 119 of file JsonParser.h.
Referenced by position().