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.

test_string_spaced_pretty.c 1.3 kB

12345678910111213141516171819202122232425262728293031323334
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stddef.h>
  4. #include <string.h>
  5. #include <assert.h>
  6. #include "json.h"
  7. int main(int argc, char **argv)
  8. {
  9. json_object *j;
  10. j = json_tokener_parse("/* more difficult test case */"
  11. "{ \"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\"] } ] } } }");
  12. printf("flags = 0:\n%s\n\n",
  13. json_object_to_json_string_ext(j, 0));
  14. printf("flags = JSON_C_TO_STRING_SPACED:\n%s\n\n",
  15. json_object_to_json_string_ext(j, JSON_C_TO_STRING_SPACED));
  16. printf("flags = JSON_C_TO_STRING_SPACED|JSON_C_TO_STRING_PRETTY:\n%s\n\n",
  17. json_object_to_json_string_ext(j, JSON_C_TO_STRING_SPACED
  18. |JSON_C_TO_STRING_PRETTY));
  19. printf("flags = JSON_C_TO_STRING_SPACED|JSON_C_TO_STRING_PRETTY|JSON_C_TO_STRING_PRETTY_TAB:\n%s\n",
  20. json_object_to_json_string_ext(j, JSON_C_TO_STRING_SPACED
  21. |JSON_C_TO_STRING_PRETTY
  22. |JSON_C_TO_STRING_PRETTY_TAB));
  23. json_object_put(j);
  24. return EXIT_SUCCESS;
  25. }