test2.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stddef.h>
  4. #include <string.h>
  5. #include "json.h"
  6. #include "parse_flags.h"
  7. #ifdef TEST_FORMATTED
  8. #define json_object_to_json_string(obj) json_object_to_json_string_ext(obj,sflags)
  9. #else
  10. /* no special define */
  11. #endif
  12. int main(int argc, char **argv)
  13. {
  14. json_object *new_obj;
  15. #ifdef TEST_FORMATTED
  16. int sflags = 0;
  17. #endif
  18. MC_SET_DEBUG(1);
  19. #ifdef TEST_FORMATTED
  20. sflags = parse_flags(argc, argv);
  21. #endif
  22. new_obj = json_tokener_parse("/* more difficult test case */"
  23. "{ \"glossary\": { \"title\": \"example glossary\", \"GlossDiv\": { \"title\": \"S\", \"GlossList\": [ { \"ID\": \"SGML\", \"SortAs\": \"SGML\", \"GlossTerm\": \"Standard Generalized Markup Language\", \"Acronym\": \"SGML\", \"Abbrev\": \"ISO 8879:1986\", \"GlossDef\": \"A meta-markup language, used to create markup languages such as DocBook.\", \"GlossSeeAlso\": [\"GML\", \"XML\", \"markup\"] } ] } } }");
  24. printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
  25. json_object_put(new_obj);
  26. return EXIT_SUCCESS;
  27. }