CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
jsmn.h File Reference

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"
Include dependency graph for jsmn.h:
This graph shows which files directly or indirectly include this file:

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)

Detailed Description

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.

Macro Definition Documentation

◆ JSMN_PARENT_LINKS

#define JSMN_PARENT_LINKS

Definition at line 13 of file jsmn.h.

Enumeration Type Documentation

◆ jsmnerr

enum jsmnerr
Enumerator
JSMN_ERROR_NOMEM 
JSMN_ERROR_INVAL 
JSMN_ERROR_PART 

Definition at line 36 of file jsmn.h.

◆ jsmntype_t

enum jsmntype_t

JSON type identifier.

Basic types are: o Object o Array o String o Other primitive: number, boolean (true/false) or null

Enumerator
JSMN_UNDEFINED 
JSMN_OBJECT 
JSMN_ARRAY 
JSMN_STRING 
JSMN_PRIMITIVE 

Definition at line 28 of file jsmn.h.

Function Documentation

◆ AddToJSONRoot()

std::string AddToJSONRoot ( const char * json,
const char * subJSON )

◆ GetJSONArrayIndexes()

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 )

◆ GetJSONChildArrayIndexes() [1/2]

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.

◆ GetJSONChildArrayIndexes() [2/2]

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.

◆ GetJSONChildValue()

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().

◆ GetJSONChildValueFloat64()

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().

◆ GetJSONChildValueInt64()

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().

◆ GetJSONChildValueString()

std::string GetJSONChildValueString ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
int parent,
jsmntype_t type = JSMN_UNDEFINED )

◆ GetJSONChildValueUint64()

uint64 GetJSONChildValueUint64 ( jsmntok_t * tokens,
int tokenCount,
const char * json,
const char * key,
int parent,
jsmntype_t type = JSMN_UNDEFINED )

◆ GetJSONToken()

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.

◆ GetJSONTokenLevel()

int GetJSONTokenLevel ( jsmntok_t * tokens,
int startToken )

Definition at line 317 of file jsmn.cpp.

References jsmntok_t::parent.

Referenced by GetJSONArrayIndexes(), and GetJSONValue().

◆ GetJSONValue() [1/2]

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.

◆ GetJSONValue() [2/2]

◆ GetJSONValueFloat64() [1/2]

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().

◆ GetJSONValueFloat64() [2/2]

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().

◆ GetJSONValueInt64() [1/2]

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().

◆ GetJSONValueInt64() [2/2]

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().

◆ GetJSONValueString() [1/2]

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().

◆ GetJSONValueString() [2/2]

std::string GetJSONValueString ( jsmntok_t * tokens,
int tokenCount,
const char * json,
int token )

◆ GetJSONValueUint64() [1/2]

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().

◆ GetJSONValueUint64() [2/2]

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().

◆ jsmn_init()

◆ jsmn_parse()