TI Utilities API  1.10.00.09
json.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2018, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
282 #ifndef ti_utils_json_Json__include
283 #define ti_utils_json_Json__include
284 
287 
288 /*
289  * ======== json.h ========
290  * @brief Contains JSON library APIs
291  */
292 
293 #include <stdlib.h>
294 #include <string.h>
295 #include "json_engine.h"
296 
297 #ifdef __cplusplus
298 extern "C" {
299 #endif
300 
301 typedef size_t Json_Handle;
302 
303 #define JSON_DEFAULT_SIZE (1024u)
304 
334 int16_t Json_createTemplate(Json_Handle *templateHandle,
335  const char *templateString, uint16_t templateStringLen);
336 
337 
361 int16_t Json_destroyTemplate(Json_Handle templateHandle);
362 
389 int16_t Json_createObject(Json_Handle *objHandle, Json_Handle templateHandle,
390  uint16_t maxObjectSize);
391 
392 
410 int16_t Json_destroyObject(Json_Handle objHandle);
411 
434 int16_t Json_parse(Json_Handle objHandle, char *jsonText, uint16_t jsonTextLen);
435 
436 
465 int16_t Json_getArrayMembersCount(Json_Handle objHandle, const char *pKey);
466 
467 
505 int16_t Json_getValue(Json_Handle objHandle, const char *pKey, void *pValue,
506  uint16_t *maxValueSize);
507 
508 
544 int16_t Json_setValue(Json_Handle objHandle, const char *pKey, void *pValue,
545  uint16_t valueSize);
546 
547 
575 int16_t Json_build(Json_Handle objHandle, char *pJsonText, uint16_t *maxTxtLen);
576 
578 #ifdef __cplusplus
579 }
580 #endif
581 
582 #endif
int16_t Json_setValue(Json_Handle objHandle, const char *pKey, void *pValue, uint16_t valueSize)
Sets the value for the provided key.
int16_t Json_parse(Json_Handle objHandle, char *jsonText, uint16_t jsonTextLen)
This function converts the json text into internal representation.
int16_t Json_getArrayMembersCount(Json_Handle objHandle, const char *pKey)
Retrieve the number of array elements in the provided key.
int16_t Json_getValue(Json_Handle objHandle, const char *pKey, void *pValue, uint16_t *maxValueSize)
This function retrieves value from json.
size_t Json_Handle
Definition: json.h:301
int16_t Json_build(Json_Handle objHandle, char *pJsonText, uint16_t *maxTxtLen)
This function builds the internal json into a text json.
int16_t Json_createTemplate(Json_Handle *templateHandle, const char *templateString, uint16_t templateStringLen)
This function creates internal template from the template text.
int16_t Json_destroyObject(Json_Handle objHandle)
Free the internal json memory.
int16_t Json_createObject(Json_Handle *objHandle, Json_Handle templateHandle, uint16_t maxObjectSize)
This function creates an empty Json object.
int16_t Json_destroyTemplate(Json_Handle templateHandle)
This function frees the internal template memory.
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale