|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Third-party (vendored): jsmn minimalistic JSON tokenizer by Serge Zaitsev (MIT licence), with local CMSDK adaptations (Utils.h include, C++ helpers). More...
#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <vector>#include "Utils.h"Go to the source code of this file.
Classes | |
| struct | jsmntok_t |
| JSON token description. More... | |
| struct | jsmn_parser |
| JSON parser. More... | |
Macros | |
| #define | JSMN_PARENT_LINKS |
Enumerations | |
| enum | jsmntype_t { JSMN_UNDEFINED = 0 , JSMN_OBJECT = 1 , JSMN_ARRAY = 2 , JSMN_STRING = 3 , JSMN_PRIMITIVE = 4 } |
| JSON type identifier. More... | |
| enum | jsmnerr { JSMN_ERROR_NOMEM = -1 , JSMN_ERROR_INVAL = -2 , JSMN_ERROR_PART = -3 } |
Functions | |
| void | jsmn_init (jsmn_parser *parser) |
| Create JSON parser over an array of tokens. | |
| int | jsmn_parse (jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens) |
| Run JSON parser. | |
| int | GetJSONTokenLevel (jsmntok_t *tokens, int startToken) |
| const char * | GetJSONValue (jsmntok_t *tokens, int tokenCount, const char *json, int token, int &valLength) |
| std::string | GetJSONValueString (jsmntok_t *tokens, int tokenCount, const char *json, int token) |
| int64 | GetJSONValueInt64 (jsmntok_t *tokens, int tokenCount, const char *json, int token) |
| uint64 | GetJSONValueUint64 (jsmntok_t *tokens, int tokenCount, const char *json, int token) |
| float64 | GetJSONValueFloat64 (jsmntok_t *tokens, int tokenCount, const char *json, int token) |
| int | GetJSONToken (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type=JSMN_UNDEFINED) |
| const char * | GetJSONValue (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type, int &valLength, int level=0, int instance=0) |
| std::string | GetJSONValueString (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type=JSMN_UNDEFINED, int level=0, int instance=0) |
| int64 | GetJSONValueInt64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type=JSMN_UNDEFINED, int level=0, int instance=0) |
| uint64 | GetJSONValueUint64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type=JSMN_UNDEFINED, int level=0, int instance=0) |
| float64 | GetJSONValueFloat64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type=JSMN_UNDEFINED, int level=0, int instance=0) |
| const char * | GetJSONChildValue (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type, int &valLength) |
| std::string | GetJSONChildValueString (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type=JSMN_UNDEFINED) |
| int64 | GetJSONChildValueInt64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type=JSMN_UNDEFINED) |
| uint64 | GetJSONChildValueUint64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type=JSMN_UNDEFINED) |
| float64 | GetJSONChildValueFloat64 (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type=JSMN_UNDEFINED) |
| std::vector< int > | GetJSONArrayIndexes (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, jsmntype_t type=JSMN_UNDEFINED, int level=0, int instance=0) |
| std::vector< int > | GetJSONChildArrayIndexes (jsmntok_t *tokens, int tokenCount, const char *json, const char *key, int parent, jsmntype_t type=JSMN_UNDEFINED) |
| std::vector< int > | GetJSONChildArrayIndexes (jsmntok_t *tokens, int tokenCount, const char *json, int parent, jsmntype_t type=JSMN_UNDEFINED) |
| std::string | AddToJSONRoot (const char *json, const char *subJSON) |
Third-party (vendored): jsmn minimalistic JSON tokenizer by Serge Zaitsev (MIT licence), with local CMSDK adaptations (Utils.h include, C++ helpers).
Not part of the CMSDK documentation remediation.
Definition in file jsmn.h.
| enum jsmnerr |
| enum jsmntype_t |
| std::string AddToJSONRoot | ( | const char * | json, |
| const char * | subJSON ) |
Definition at line 539 of file jsmn.cpp.
References cmlabs::utils::laststrstr(), and cmlabs::utils::StringFormat().
Referenced by cmlabs::RequestGateway::replyToClient().
| std::vector< int > GetJSONArrayIndexes | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| jsmntype_t | type = JSMN_UNDEFINED, | ||
| int | level = 0, | ||
| int | instance = 0 ) |
Definition at line 464 of file jsmn.cpp.
References GetJSONTokenLevel(), and JSMN_UNDEFINED.
Referenced by cmlabs::RESTParser::extractParameters(), and cmlabs::RESTParser::extractParameters().
| std::vector< int > GetJSONChildArrayIndexes | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| int | parent, | ||
| jsmntype_t | type = JSMN_UNDEFINED ) |
Definition at line 492 of file jsmn.cpp.
References JSMN_UNDEFINED.
| std::vector< int > GetJSONChildArrayIndexes | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| int | parent, | ||
| jsmntype_t | type = JSMN_UNDEFINED ) |
Definition at line 519 of file jsmn.cpp.
References JSMN_UNDEFINED.
| const char * GetJSONChildValue | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| int | parent, | ||
| jsmntype_t | type, | ||
| int & | valLength ) |
Definition at line 398 of file jsmn.cpp.
References jsmntok_t::end, JSMN_UNDEFINED, and jsmntok_t::start.
Referenced by GetJSONChildValueString().
| float64 GetJSONChildValueFloat64 | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| int | parent, | ||
| jsmntype_t | type = JSMN_UNDEFINED ) |
Definition at line 457 of file jsmn.cpp.
References cmlabs::utils::Ascii2Float64(), and GetJSONChildValueString().
| int64 GetJSONChildValueInt64 | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| int | parent, | ||
| jsmntype_t | type = JSMN_UNDEFINED ) |
Definition at line 449 of file jsmn.cpp.
References cmlabs::utils::Ascii2Int64(), and GetJSONChildValueString().
| std::string GetJSONChildValueString | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| int | parent, | ||
| jsmntype_t | type = JSMN_UNDEFINED ) |
Definition at line 441 of file jsmn.cpp.
References GetJSONChildValue().
Referenced by GetJSONChildValueFloat64(), GetJSONChildValueInt64(), GetJSONChildValueUint64(), and cmlabs::RequestGateway::receiveWebsocketData().
| uint64 GetJSONChildValueUint64 | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| int | parent, | ||
| jsmntype_t | type = JSMN_UNDEFINED ) |
Definition at line 453 of file jsmn.cpp.
References cmlabs::utils::Ascii2Uint64(), and GetJSONChildValueString().
Referenced by cmlabs::RequestGateway::receiveWebsocketData().
| int GetJSONToken | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| int | parent, | ||
| jsmntype_t | type = JSMN_UNDEFINED ) |
Definition at line 328 of file jsmn.cpp.
References JSMN_UNDEFINED.
| int GetJSONTokenLevel | ( | jsmntok_t * | tokens, |
| int | startToken ) |
Definition at line 317 of file jsmn.cpp.
References jsmntok_t::parent.
Referenced by GetJSONArrayIndexes(), and GetJSONValue().
| const char * GetJSONValue | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| jsmntype_t | type, | ||
| int & | valLength, | ||
| int | level = 0, | ||
| int | instance = 0 ) |
Definition at line 375 of file jsmn.cpp.
References jsmntok_t::end, GetJSONTokenLevel(), JSMN_UNDEFINED, and jsmntok_t::start.
| const char * GetJSONValue | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| int | token, | ||
| int & | valLength ) |
Definition at line 347 of file jsmn.cpp.
References jsmntok_t::end, and jsmntok_t::start.
Referenced by cmlabs::RESTParser::extractArrayParameters(), cmlabs::RESTParser::extractArrayParameters(), cmlabs::RESTParser::extractParameters(), cmlabs::RESTParser::extractParameters(), cmlabs::RequestClient::GetJSONReplyParameter(), GetJSONValueString(), and GetJSONValueString().
| float64 GetJSONValueFloat64 | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| jsmntype_t | type = JSMN_UNDEFINED, | ||
| int | level = 0, | ||
| int | instance = 0 ) |
Definition at line 436 of file jsmn.cpp.
References cmlabs::utils::Ascii2Float64(), and GetJSONValueString().
| float64 GetJSONValueFloat64 | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| int | token ) |
Definition at line 370 of file jsmn.cpp.
References cmlabs::utils::Ascii2Float64(), and GetJSONValueString().
| int64 GetJSONValueInt64 | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| jsmntype_t | type = JSMN_UNDEFINED, | ||
| int | level = 0, | ||
| int | instance = 0 ) |
Definition at line 428 of file jsmn.cpp.
References cmlabs::utils::Ascii2Int64(), and GetJSONValueString().
| int64 GetJSONValueInt64 | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| int | token ) |
Definition at line 362 of file jsmn.cpp.
References cmlabs::utils::Ascii2Int64(), and GetJSONValueString().
| std::string GetJSONValueString | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| jsmntype_t | type = JSMN_UNDEFINED, | ||
| int | level = 0, | ||
| int | instance = 0 ) |
Definition at line 420 of file jsmn.cpp.
References GetJSONValue().
| std::string GetJSONValueString | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| int | token ) |
Definition at line 354 of file jsmn.cpp.
References GetJSONValue().
Referenced by GetJSONValueFloat64(), GetJSONValueFloat64(), GetJSONValueInt64(), GetJSONValueInt64(), GetJSONValueUint64(), and GetJSONValueUint64().
| uint64 GetJSONValueUint64 | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| const char * | key, | ||
| jsmntype_t | type = JSMN_UNDEFINED, | ||
| int | level = 0, | ||
| int | instance = 0 ) |
Definition at line 432 of file jsmn.cpp.
References cmlabs::utils::Ascii2Uint64(), and GetJSONValueString().
| uint64 GetJSONValueUint64 | ( | jsmntok_t * | tokens, |
| int | tokenCount, | ||
| const char * | json, | ||
| int | token ) |
Definition at line 366 of file jsmn.cpp.
References cmlabs::utils::Ascii2Uint64(), and GetJSONValueString().
| void jsmn_init | ( | jsmn_parser * | parser | ) |
Create JSON parser over an array of tokens.
Create JSON parser over an array of tokens.
Definition at line 311 of file jsmn.cpp.
References jsmn_parser::pos, jsmn_parser::toknext, and jsmn_parser::toksuper.
Referenced by cmlabs::RESTParser::extractArrayParameters(), cmlabs::RESTParser::extractArrayParameters(), cmlabs::RESTParser::extractParameters(), cmlabs::RESTParser::extractParameters(), cmlabs::RequestClient::GetJSONReplyParameter(), and cmlabs::RequestGateway::receiveWebsocketData().
| int jsmn_parse | ( | jsmn_parser * | parser, |
| const char * | js, | ||
| size_t | len, | ||
| jsmntok_t * | tokens, | ||
| unsigned int | num_tokens ) |
Run JSON parser.
It parses a JSON data string into and array of tokens, each describing a single JSON object.
Run JSON parser.
Definition at line 156 of file jsmn.cpp.
References jsmntok_t::end, jsmn_alloc_token(), JSMN_ARRAY, JSMN_ERROR_INVAL, JSMN_ERROR_NOMEM, JSMN_ERROR_PART, JSMN_OBJECT, jsmn_parse_primitive(), jsmn_parse_string(), JSMN_STRING, jsmntok_t::parent, jsmn_parser::pos, jsmntok_t::size, jsmntok_t::start, jsmn_parser::toknext, jsmn_parser::toksuper, and jsmntok_t::type.
Referenced by cmlabs::RESTParser::extractArrayParameters(), cmlabs::RESTParser::extractArrayParameters(), cmlabs::RESTParser::extractParameters(), cmlabs::RESTParser::extractParameters(), cmlabs::RequestClient::GetJSONReplyParameter(), and cmlabs::RequestGateway::receiveWebsocketData().