cJSON_Utils.h 1.1 KB

12345678910111213141516171819202122
  1. #include "cJSON.h"
  2. // Implement RFC6901 (https://tools.ietf.org/html/rfc6901) JSON Pointer spec.
  3. cJSON *cJSONUtils_GetPointer(cJSON *object,const char *pointer);
  4. // Implement RFC6902 (https://tools.ietf.org/html/rfc6902) JSON Patch spec.
  5. cJSON* cJSONUtils_GeneratePatches(cJSON *from,cJSON *to);
  6. void cJSONUtils_AddPatchToArray(cJSON *array,const char *op,const char *path,cJSON *val); // Utility for generating patch array entries.
  7. int cJSONUtils_ApplyPatches(cJSON *object,cJSON *patches); // Returns 0 for success.
  8. // Note that ApplyPatches is NOT atomic on failure. To implement an atomic ApplyPatches, use:
  9. //int cJSONUtils_AtomicApplyPatches(cJSON **object, cJSON *patches)
  10. //{
  11. // cJSON *modme=cJSON_Duplicate(*object,1);
  12. // int error=cJSONUtils_ApplyPatches(modme,patches);
  13. // if (!error) {cJSON_Delete(*object);*object=modme;}
  14. // else cJSON_Delete(modme);
  15. // return error;
  16. //}
  17. // Code not added to library since this strategy is a LOT slower.
  18. char *cJSONUtils_FindPointerFromObjectTo(cJSON *object,cJSON *target); // Given a root object and a target object, construct a pointer from one to the other.