You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

json_patch.h 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2021 Alexadru Ardelean.
  3. *
  4. * This is free software; you can redistribute it and/or modify
  5. * it under the terms of the MIT license. See COPYING for details.
  6. *
  7. */
  8. /**
  9. * @file
  10. * @brief JSON Patch (RFC 6902) implementation for manipulating JSON objects
  11. */
  12. #ifndef _json_patch_h_
  13. #define _json_patch_h_
  14. #include "json_pointer.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /**
  19. * Apply the JSON patch to the base object.
  20. * The patch object must be formatted as per RFC 6902.
  21. * If the patch is not correctly formatted, an error will
  22. * be returned.
  23. *
  24. * The original `base` object will first be copied, and then
  25. * the patch will be applied.
  26. * If anything fails during patching, the `res` object will be
  27. * NULL and the function will return a negative result.
  28. *
  29. * @param base the JSON object which to patch
  30. * @param patch the JSON object that describes the patch to be applied
  31. * @param the resulting patched JSON object
  32. *
  33. * @return negative if an error (or not found), or 0 if succeeded
  34. */
  35. JSON_EXPORT int json_patch_apply(struct json_object *base, struct json_object *patch,
  36. struct json_object **res);
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40. #endif