Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
jsmn.h
00001 #ifndef __JSMN_H_ 00002 #define __JSMN_H_ 00003 00004 /** 00005 * JSON type identifier. Basic types are: 00006 * o Object 00007 * o Array 00008 * o String 00009 * o Other primitive: number, boolean (true/false) or null 00010 */ 00011 typedef enum { 00012 JSMN_PRIMITIVE = 0, 00013 JSMN_OBJECT = 1, 00014 JSMN_ARRAY = 2, 00015 JSMN_STRING = 3 00016 } jsmntype_t; 00017 00018 typedef enum { 00019 /* Not enough tokens were provided */ 00020 JSMN_ERROR_NOMEM = -1, 00021 /* Invalid character inside JSON string */ 00022 JSMN_ERROR_INVAL = -2, 00023 /* The string is not a full JSON packet, more bytes expected */ 00024 JSMN_ERROR_PART = -3, 00025 /* Everything was fine */ 00026 JSMN_SUCCESS = 0 00027 } jsmnerr_t; 00028 00029 /** 00030 * JSON token description. 00031 * @param type type (object, array, string etc.) 00032 * @param start start position in JSON data string 00033 * @param end end position in JSON data string 00034 */ 00035 typedef struct { 00036 jsmntype_t type; 00037 int start; 00038 int end; 00039 int size; 00040 #ifdef JSMN_PARENT_LINKS 00041 int parent; 00042 #endif 00043 } jsmntok_t; 00044 00045 /** 00046 * JSON parser. Contains an array of token blocks available. Also stores 00047 * the string being parsed now and current position in that string 00048 */ 00049 typedef struct { 00050 unsigned int pos; /* offset in the JSON string */ 00051 int toknext; /* next token to allocate */ 00052 int toksuper; /* superior token node, e.g parent object or array */ 00053 } jsmn_parser; 00054 00055 /** 00056 * Create JSON parser over an array of tokens 00057 */ 00058 void jsmn_init(jsmn_parser *parser); 00059 00060 /** 00061 * Run JSON parser. It parses a JSON data string into and array of tokens, each describing 00062 * a single JSON object. 00063 */ 00064 jsmnerr_t jsmn_parse(jsmn_parser *parser, char *js, 00065 jsmntok_t *tokens, unsigned int num_tokens); 00066 00067 #endif /* __JSMN_H_ */
Generated on Sat Jul 30 2022 22:42:10 by
1.7.2