qJSON is a minimal, in-place, zero-allocation JSON packer and unpacker. More...
#include "qev.h"Go to the source code of this file.
Enumerations | |
| enum | qev_json_status { QEV_JSON_OK, QEV_JSON_SPECMEM, QEV_JSON_INSPEC, QEV_JSON_INVAL, QEV_JSON_MISMATCH } |
| The maximum number of parts the spec may contain (objects, arrays, values). More... | |
Functions | |
| enum qev_json_status | qev_json_unpack (gchar *json, guint *parsed, const gchar *spec,...) |
| Variable arguments form of qev_json_vunpack(). | |
| enum qev_json_status | qev_json_vunpack (gchar *json, guint *parsed, const gchar *spec, va_list args) |
| Unpack the given JSON object into the given variables. More... | |
| enum qev_json_status | qev_json_pack (GString *buff, const gchar *spec,...) |
| Variable arguments form of qev_json_vpack(). | |
| enum qev_json_status | qev_json_vpack (GString *buff, const gchar *spec, va_list args) |
| Packs the given values into a JSON object. More... | |
qJSON is a minimal, in-place, zero-allocation JSON packer and unpacker.
The following specs are supported:
| enum qev_json_status |
The maximum number of parts the spec may contain (objects, arrays, values).
Possible return codes of any operation
| enum qev_json_status qev_json_vpack | ( | GString * | buff, |
| const gchar * | spec, | ||
| va_list | args | ||
| ) |
Packs the given values into a JSON object.
| buff | Where the packed JSON should be placed. The JSON is only appended to the string, so if you only want JSON in the string, be sure the string is empty before passing it in. |
| spec | The json-ish spec used to pack into JSON. |
| args | The values to pack. |
| enum qev_json_status qev_json_vunpack | ( | gchar * | json, |
| guint * | parsed, | ||
| const gchar * | spec, | ||
| va_list | args | ||
| ) |
Unpack the given JSON object into the given variables.
| json | The JSON to unpack. This will be modified in place and unpacked into the values, so once this becomes invalid, all gchar* values passed in also become invalid. | |
| [out] | parsed | The number of characters parsed. When json_ok, this is the number of JSON characters parsed (it's possible that this is less than the length of the JSON string when all values are found before parsing finishes). When json_inspec, this is the number of spec characters parsed. Practically speaking, on error, the character at this offset is the beginning of the parse error. [allow-null] |
| spec | The json-ish spec used to unpack the JSON into the given variables. | |
| args | Where the found values should be placed. |
1.8.6