![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
DIYmall 0.96" Inch I2c IIC Serial 128x64 Oled LCD LED White Display Module
Dependencies: Adafruit_GFX SDFileSystem
Fork of ATT_AWS_IoT_demo by
AWS_openssl/aws_iot_src/utils/jsmn.h@15:6f2798e45099, 2016-12-01 (annotated)
- Committer:
- ampembeng
- Date:
- Thu Dec 01 18:05:38 2016 +0000
- Revision:
- 15:6f2798e45099
Initial commit. Demo works with both the FRDM wired Ethernet and the Avnet Shield wireless modem.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ampembeng | 15:6f2798e45099 | 1 | /* |
ampembeng | 15:6f2798e45099 | 2 | * Copyright (c) 2010 Serge A. Zaitsev |
ampembeng | 15:6f2798e45099 | 3 | * |
ampembeng | 15:6f2798e45099 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
ampembeng | 15:6f2798e45099 | 5 | * of this software and associated documentation files (the "Software"), to deal |
ampembeng | 15:6f2798e45099 | 6 | * in the Software without restriction, including without limitation the rights |
ampembeng | 15:6f2798e45099 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
ampembeng | 15:6f2798e45099 | 8 | * copies of the Software, and to permit persons to whom the Software is |
ampembeng | 15:6f2798e45099 | 9 | * furnished to do so, subject to the following conditions: |
ampembeng | 15:6f2798e45099 | 10 | * |
ampembeng | 15:6f2798e45099 | 11 | * The above copyright notice and this permission notice shall be included in |
ampembeng | 15:6f2798e45099 | 12 | * all copies or substantial portions of the Software. |
ampembeng | 15:6f2798e45099 | 13 | * |
ampembeng | 15:6f2798e45099 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
ampembeng | 15:6f2798e45099 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
ampembeng | 15:6f2798e45099 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
ampembeng | 15:6f2798e45099 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
ampembeng | 15:6f2798e45099 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ampembeng | 15:6f2798e45099 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
ampembeng | 15:6f2798e45099 | 20 | * THE SOFTWARE. |
ampembeng | 15:6f2798e45099 | 21 | */ |
ampembeng | 15:6f2798e45099 | 22 | |
ampembeng | 15:6f2798e45099 | 23 | /** |
ampembeng | 15:6f2798e45099 | 24 | * @file jsmn.h |
ampembeng | 15:6f2798e45099 | 25 | * @brief Definition of the JSMN (Jasmine) JSON parser. |
ampembeng | 15:6f2798e45099 | 26 | * |
ampembeng | 15:6f2798e45099 | 27 | * For more information on JSMN: |
ampembeng | 15:6f2798e45099 | 28 | * @see http://zserge.com/jsmn.html |
ampembeng | 15:6f2798e45099 | 29 | */ |
ampembeng | 15:6f2798e45099 | 30 | |
ampembeng | 15:6f2798e45099 | 31 | #ifndef __JSMN_H_ |
ampembeng | 15:6f2798e45099 | 32 | #define __JSMN_H_ |
ampembeng | 15:6f2798e45099 | 33 | #include <stddef.h> |
ampembeng | 15:6f2798e45099 | 34 | #define JSMN_STRICT |
ampembeng | 15:6f2798e45099 | 35 | #ifdef __cplusplus |
ampembeng | 15:6f2798e45099 | 36 | extern "C" { |
ampembeng | 15:6f2798e45099 | 37 | #endif |
ampembeng | 15:6f2798e45099 | 38 | |
ampembeng | 15:6f2798e45099 | 39 | /** |
ampembeng | 15:6f2798e45099 | 40 | * JSON type identifier. Basic types are: |
ampembeng | 15:6f2798e45099 | 41 | * o Object |
ampembeng | 15:6f2798e45099 | 42 | * o Array |
ampembeng | 15:6f2798e45099 | 43 | * o String |
ampembeng | 15:6f2798e45099 | 44 | * o Other primitive: number, boolean (true/false) or null |
ampembeng | 15:6f2798e45099 | 45 | */ |
ampembeng | 15:6f2798e45099 | 46 | typedef enum { |
ampembeng | 15:6f2798e45099 | 47 | JSMN_PRIMITIVE = 0, JSMN_OBJECT = 1, JSMN_ARRAY = 2, JSMN_STRING = 3 |
ampembeng | 15:6f2798e45099 | 48 | } jsmntype_t; |
ampembeng | 15:6f2798e45099 | 49 | |
ampembeng | 15:6f2798e45099 | 50 | typedef enum { |
ampembeng | 15:6f2798e45099 | 51 | /* Not enough tokens were provided */ |
ampembeng | 15:6f2798e45099 | 52 | JSMN_ERROR_NOMEM = -1, |
ampembeng | 15:6f2798e45099 | 53 | /* Invalid character inside JSON string */ |
ampembeng | 15:6f2798e45099 | 54 | JSMN_ERROR_INVAL = -2, |
ampembeng | 15:6f2798e45099 | 55 | /* The string is not a full JSON packet, more bytes expected */ |
ampembeng | 15:6f2798e45099 | 56 | JSMN_ERROR_PART = -3, |
ampembeng | 15:6f2798e45099 | 57 | } jsmnerr_t; |
ampembeng | 15:6f2798e45099 | 58 | |
ampembeng | 15:6f2798e45099 | 59 | /** |
ampembeng | 15:6f2798e45099 | 60 | * JSON token description. |
ampembeng | 15:6f2798e45099 | 61 | * @param type type (object, array, string etc.) |
ampembeng | 15:6f2798e45099 | 62 | * @param start start position in JSON data string |
ampembeng | 15:6f2798e45099 | 63 | * @param end end position in JSON data string |
ampembeng | 15:6f2798e45099 | 64 | */ |
ampembeng | 15:6f2798e45099 | 65 | typedef struct { |
ampembeng | 15:6f2798e45099 | 66 | jsmntype_t type; |
ampembeng | 15:6f2798e45099 | 67 | int start; |
ampembeng | 15:6f2798e45099 | 68 | int end; |
ampembeng | 15:6f2798e45099 | 69 | int size; |
ampembeng | 15:6f2798e45099 | 70 | #ifdef JSMN_PARENT_LINKS |
ampembeng | 15:6f2798e45099 | 71 | int parent; |
ampembeng | 15:6f2798e45099 | 72 | #endif |
ampembeng | 15:6f2798e45099 | 73 | } jsmntok_t; |
ampembeng | 15:6f2798e45099 | 74 | |
ampembeng | 15:6f2798e45099 | 75 | /** |
ampembeng | 15:6f2798e45099 | 76 | * JSON parser. Contains an array of token blocks available. Also stores |
ampembeng | 15:6f2798e45099 | 77 | * the string being parsed now and current position in that string |
ampembeng | 15:6f2798e45099 | 78 | */ |
ampembeng | 15:6f2798e45099 | 79 | typedef struct { |
ampembeng | 15:6f2798e45099 | 80 | unsigned int pos; /* offset in the JSON string */ |
ampembeng | 15:6f2798e45099 | 81 | unsigned int toknext; /* next token to allocate */ |
ampembeng | 15:6f2798e45099 | 82 | int toksuper; /* superior token node, e.g parent object or array */ |
ampembeng | 15:6f2798e45099 | 83 | } jsmn_parser; |
ampembeng | 15:6f2798e45099 | 84 | |
ampembeng | 15:6f2798e45099 | 85 | /** |
ampembeng | 15:6f2798e45099 | 86 | * Create JSON parser over an array of tokens |
ampembeng | 15:6f2798e45099 | 87 | */ |
ampembeng | 15:6f2798e45099 | 88 | void jsmn_init(jsmn_parser *parser); |
ampembeng | 15:6f2798e45099 | 89 | |
ampembeng | 15:6f2798e45099 | 90 | /** |
ampembeng | 15:6f2798e45099 | 91 | * Run JSON parser. It parses a JSON data string into and array of tokens, each describing |
ampembeng | 15:6f2798e45099 | 92 | * a single JSON object. |
ampembeng | 15:6f2798e45099 | 93 | */ |
ampembeng | 15:6f2798e45099 | 94 | jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len, |
ampembeng | 15:6f2798e45099 | 95 | jsmntok_t *tokens, unsigned int num_tokens); |
ampembeng | 15:6f2798e45099 | 96 | |
ampembeng | 15:6f2798e45099 | 97 | #ifdef __cplusplus |
ampembeng | 15:6f2798e45099 | 98 | } |
ampembeng | 15:6f2798e45099 | 99 | #endif |
ampembeng | 15:6f2798e45099 | 100 | |
ampembeng | 15:6f2798e45099 | 101 | #endif /* __JSMN_H_ */ |
ampembeng | 15:6f2798e45099 | 102 |