iot_water_monitor_v2
Dependencies: easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code
jsmn.h
00001 /* Author: Faheem Inayat 00002 * Created by "Night Crue" Team @ TechShop San Jose, CA 00003 * 00004 * --- DISCLAIMER --- 00005 * This code is a modified version of original JSMN lirary, written by 00006 * *** Serge A. Zaitsev *** 00007 * and hosted at https://github.com/zserge/jsmn 00008 * Any modification to the original source is not guaranteed to be included 00009 * in this version. As of writing of this file, the original source is 00010 * licensed under MIT License 00011 * (http://www.opensource.org/licenses/mit-license.php). 00012 */ 00013 00014 #ifndef __JSMN_H_ 00015 #define __JSMN_H_ 00016 00017 #include <stddef.h> 00018 00019 #ifdef __cplusplus 00020 extern "C" 00021 { 00022 #endif 00023 /* 00024 Modified version of original jsmn lib ... added a type "JSMN_KEY" and enabled 00025 parent-pointers and strict JSON check. 00026 */ 00027 /** 00028 * JSON type identifier. Basic types are: 00029 * o Object 00030 * o Array 00031 * o String 00032 * o Other primitive: number, boolean (true/false) or null 00033 */ 00034 typedef enum 00035 { 00036 JSMN_UNDEFINED = 0, 00037 JSMN_OBJECT = 1, 00038 JSMN_ARRAY = 2, 00039 JSMN_STRING = 3, 00040 JSMN_PRIMITIVE = 4, 00041 JSMN_KEY = 5 00042 } jsmntype_t; 00043 00044 enum jsmnerr 00045 { 00046 /* Not enough tokens were provided */ 00047 JSMN_ERROR_NOMEM = -1, 00048 /* Invalid character inside JSON string */ 00049 JSMN_ERROR_INVAL = -2, 00050 /* The string is not a full JSON packet, more bytes expected */ 00051 JSMN_ERROR_PART = -3 00052 }; 00053 00054 /** 00055 * JSON token description. 00056 * @param type type (object, array, string etc.) 00057 * @param start start position in JSON data string 00058 * @param end end position in JSON data string 00059 */ 00060 typedef struct 00061 { 00062 jsmntype_t type; 00063 int start; 00064 int end; 00065 int parent; 00066 int childCount; 00067 } jsmntok_t; 00068 00069 /** 00070 * JSON parser. Contains an array of token blocks available. Also stores 00071 * the string being parsed now and current position in that string 00072 */ 00073 typedef struct 00074 { 00075 unsigned int pos; /* offset in the JSON string */ 00076 unsigned int toknext; /* next token to allocate */ 00077 int toksuper; /* superior token node, e.g parent object or array */ 00078 } jsmn_parser; 00079 00080 /** 00081 * Create JSON parser over an array of tokens 00082 */ 00083 void jsmn_init ( jsmn_parser *parser ); 00084 00085 /** 00086 * Run JSON parser. It parses a JSON data string into and array of tokens, each describing 00087 * a single JSON object. 00088 */ 00089 int jsmn_parse ( jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, unsigned int num_tokens ); 00090 00091 #ifdef __cplusplus 00092 } 00093 #endif 00094 00095 #endif /* __JSMN_H_ */ 00096
Generated on Tue Jul 12 2022 20:06:04 by 1.7.2