Wp.SpaJsonParser¶
Fields¶
None
Methods¶
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Wp.SpaJsonParser¶
New in version 0.4.8.
- classmethod new_array(json)¶
- Parameters:
json (
Wp.SpaJson
) – the spa json array to parse- Returns:
The new spa json parser
- Return type:
Creates a spa json array parser. The json object must be valid for the entire life-cycle of the returned parser.
- classmethod new_object(json)¶
- Parameters:
json (
Wp.SpaJson
) – the spa json object to parse- Returns:
The new spa json parser
- Return type:
Creates a spa json object parser. The json object must be valid for the entire life-cycle of the returned parser.
- classmethod new_undefined(json)¶
- Parameters:
json (
Wp.SpaJson
) – the spa json to parse- Returns:
The new spa json parser
- Return type:
Creates a new spa json parser for undefined type of data. The json object must be valid for the entire life-cycle of the returned parser.
This function allows creating a parser object for any type of spa json and is mostly useful to parse non-standard JSON data that should be treated as if it were an object or array, but does not start with a ‘{’ or ‘[’ character. Such data can be for instance a comma-separated list of single values (array) or key-value pairs (object). Such data is also the main configuration file, which is an object but doesn’t start with a ‘{’ character. If the data is an array or object, the parser will not enter it and the only token it will be able to parse is the same json object that is passed in as an argument. Use
Wp.SpaJsonParser.new_array
() orWp.SpaJsonParser.new_object
() to parse arrays or objects.New in version 0.5.0.
- end()¶
- get_boolean()¶
-
Gets the boolean value from a spa json parser.
- get_float()¶
-
Gets the float value from a spa json parser object.
- get_int()¶
-
Gets the int value from a spa json parser object.
- get_json()¶
- Returns:
The spa json value or
None
if it could not be obtained- Return type:
Gets the spa json value from a spa json parser object.
the returned spa json object references the original data instead of copying it, therefore the original data must be valid for the entire life-cycle of the returned object
- get_null()¶
-
Gets the null value from a spa json parser.
- get_string()¶
- Returns:
The newly allocated parsed string
- Return type:
Gets the string value from a spa json parser object.
- ref()¶
- Returns:
self with an additional reference count on it
- Return type:
Increases the reference count of a spa json parser.
- unref()¶
Decreases the reference count on self and frees it when the ref count reaches zero.