API for platform independent parsing of json files
Namespace: | dmJson |
Include: | #include <dmsdk/dlib/json.h> |
ENUMS | |
---|---|
Result | result enumeration |
Type | token type enumeration |
STRUCTS | |
---|---|
struct Node | Json node representation. |
struct Document | Json document |
FUNCTIONS | |
---|---|
Result Parse(const char* buffer, uint32_t length, Document* document) | parse json data |
Result Parse(const char* buffer, Document* document) | parse null terminated json data |
void Free(Document* document) | deallocates json document |
Result Parse(const char* buffer, uint32_t length, Document* document)
Parses an (utf-8) string into a dmJson::Document The document must later be freed with dmJson::Free()
PARAMETERS
const char* |
buffer |
The input data (Utf-8) |
uint32_t |
length |
The size of the json buffer (in bytes) |
Document* |
document |
The output document |
RETURNS
Result |
dmJson::RESULT_OK on success |
Result Parse(const char* buffer, Document* document)
Parses a null terminated (utf-8) string into a dmJson::Document The document must later be freed with dmJson::Free()
PARAMETERS
const char* |
buffer |
The input data (Utf-8) |
Document* |
document |
The output document |
RETURNS
Result |
dmJson::RESULT_OK on success |
void Free(Document* document)
Deallocates a previously created dmJson::Document
PARAMETERS
Document* |
document |
The document |
RETURNS
void |
TYPE
struct Node
Nodes are in depth-first order with sibling links for simplified traversal. NOTE: Siblings were added to support a read-only lua-view of json-data. It's currently not used and could potentially be removed for increased performance.
MEMBERS
Type |
m_Type |
Node type |
int |
m_Start |
Start index inclusive into document json-data |
int |
m_End |
End index exclusive into document json-data |
int |
m_Size |
Size. Only applicable for arrays and objects |
int |
m_Sibling |
Sibling index. -1 if no sibling |
TYPE
struct Document
Holds a full json document
MEMBERS
Node* |
m_Nodes |
Array of nodes. First node is root |
int |
m_NodeCount |
Total number of nodes |
char* |
m_Json |
Json-data (unescaped) |
void* |
m_UserData |
User-data |
Result enumeration.
dmJson::RESULT_OK |
|
dmJson::RESULT_SYNTAX_ERROR |
|
dmJson::RESULT_INCOMPLETE |
|
dmJson::RESULT_UNKNOWN |
Token type enumeration.
dmJson::TYPE_PRIMITIVE |
Number or boolean |
dmJson::TYPE_OBJECT |
Json object |
dmJson::TYPE_ARRAY |
Json array |
dmJson::TYPE_STRING |
String |