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.

test2.c 1.0 kB

12345678910111213141516171819202122232425262728293031323334
  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 */ { \"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\"] } ] } } }");
  23. printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
  24. json_object_put(new_obj);
  25. return 0;
  26. }