RTS API Documentation  1.10.11
switch_cJSON_Utils.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
3  Permission is hereby granted, free of charge, to any person obtaining a copy
4  of this software and associated documentation files (the "Software"), to deal
5  in the Software without restriction, including without limitation the rights
6  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  copies of the Software, and to permit persons to whom the Software is
8  furnished to do so, subject to the following conditions:
9  The above copyright notice and this permission notice shall be included in
10  all copies or substantial portions of the Software.
11  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17  THE SOFTWARE.
18 */
19 
20 #ifndef cJSON_Utils__h
21 #define cJSON_Utils__h
22 
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27 
28 #include "switch_cJSON.h"
29 
30 /* Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec. */
31 CJSON_PUBLIC(cJSON *) cJSONUtils_GetPointer(cJSON * const object, const char *pointer);
32 CJSON_PUBLIC(cJSON *) cJSONUtils_GetPointerCaseSensitive(cJSON * const object, const char *pointer);
33 
34 /* Implement RFC6902 (https://tools.ietf.org/html/rfc6902) JSON Patch spec. */
35 /* NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key */
36 CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatches(cJSON * const from, cJSON * const to);
37 CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatchesCaseSensitive(cJSON * const from, cJSON * const to);
38 /* Utility for generating patch array entries. */
39 CJSON_PUBLIC(void) cJSONUtils_AddPatchToArray(cJSON * const array, const char * const operation, const char * const path, const cJSON * const value);
40 /* Returns 0 for success. */
41 CJSON_PUBLIC(int) cJSONUtils_ApplyPatches(cJSON * const object, const cJSON * const patches);
42 CJSON_PUBLIC(int) cJSONUtils_ApplyPatchesCaseSensitive(cJSON * const object, const cJSON * const patches);
43 
44 /*
45 // Note that ApplyPatches is NOT atomic on failure. To implement an atomic ApplyPatches, use:
46 //int cJSONUtils_AtomicApplyPatches(cJSON **object, cJSON *patches)
47 //{
48 // cJSON *modme = cJSON_Duplicate(*object, 1);
49 // int error = cJSONUtils_ApplyPatches(modme, patches);
50 // if (!error)
51 // {
52 // cJSON_Delete(*object);
53 // *object = modme;
54 // }
55 // else
56 // {
57 // cJSON_Delete(modme);
58 // }
59 //
60 // return error;
61 //}
62 // Code not added to library since this strategy is a LOT slower.
63 */
64 
65 /* Implement RFC7386 (https://tools.ietf.org/html/rfc7396) JSON Merge Patch spec. */
66 /* target will be modified by patch. return value is new ptr for target. */
67 CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatch(cJSON *target, const cJSON * const patch);
68 CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatchCaseSensitive(cJSON *target, const cJSON * const patch);
69 /* generates a patch to move from -> to */
70 /* NOTE: This modifies objects in 'from' and 'to' by sorting the elements by their key */
71 CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatch(cJSON * const from, cJSON * const to);
72 CJSON_PUBLIC(cJSON *) cJSONUtils_GenerateMergePatchCaseSensitive(cJSON * const from, cJSON * const to);
73 
74 /* Given a root object and a target object, construct a pointer from one to the other. */
75 CJSON_PUBLIC(char *) cJSONUtils_FindPointerFromObjectTo(const cJSON * const object, const cJSON * const target);
76 
77 /* Sorts the members of the object into alphabetical order. */
78 CJSON_PUBLIC(void) cJSONUtils_SortObject(cJSON * const object);
79 CJSON_PUBLIC(void) cJSONUtils_SortObjectCaseSensitive(cJSON * const object);
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif
cJSON *const to
const char *const const char *const const cJSON *const value
const char * pointer
const cJSON *const patches
const char *const operation
const char *const const char *const path
const cJSON *const target
CJSON_PUBLIC(cJSON *) cJSONUtils_GetPointer(cJSON *const object
const cJSON *const patch