README.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. * Introduction:
  2. =============
  3. JSON (JavaScript Object Notation) is a lightweight data-interchange format.
  4. It can represent integer, real number, string, an ordered sequence of
  5. value, and a collection of name/value pairs.
  6. JsonCpp is a simple API to manipulate JSON value, handle serialization
  7. and unserialization to string.
  8. It can also preserve existing comment in unserialization/serialization steps,
  9. making it a convenient format to store user input files.
  10. Unserialization parsing is user friendly and provides precise error reports.
  11. * Building/Testing:
  12. =================
  13. JsonCpp uses Scons (http://www.scons.org) as a build system. Scons requires
  14. python to be installed (http://www.python.org).
  15. You download scons-local distribution from the following url:
  16. http://sourceforge.net/project/showfiles.php?group_id=30337&package_id=67375
  17. Unzip it in the directory where you found this README file. scons.py Should be
  18. at the same level as README.
  19. python scons.py platform=PLTFRM [TARGET]
  20. where PLTFRM may be one of:
  21. suncc Sun C++ (Solaris)
  22. vacpp Visual Age C++ (AIX)
  23. mingw
  24. msvc6 Microsoft Visual Studio 6 service pack 5-6
  25. msvc70 Microsoft Visual Studio 2002
  26. msvc71 Microsoft Visual Studio 2003
  27. msvc80 Microsoft Visual Studio 2005
  28. linux-gcc Gnu C++ (linux, also reported to work for Mac OS X)
  29. adding platform is fairly simple. You need to change the Sconstruct file
  30. to do so.
  31. and TARGET may be:
  32. check: build library and run unit tests.
  33. * Running the test manually:
  34. ==========================
  35. cd test
  36. # This will run the Reader/Writer tests
  37. python runjsontests.py "path to jsontest.exe"
  38. # This will run the Reader/Writer tests, using JSONChecker test suite
  39. # (http://www.json.org/JSON_checker/).
  40. # Notes: not all tests pass: JsonCpp is too lenient (for example,
  41. # it allows an integer to start with '0'). The goal is to improve
  42. # strict mode parsing to get all tests to pass.
  43. python runjsontests.py --with-json-checker "path to jsontest.exe"
  44. # This will run the unit tests (mostly Value)
  45. python rununittests.py "path to test_lib_json.exe"
  46. You can run the tests using valgrind:
  47. python rununittests.py --valgrind "path to test_lib_json.exe"
  48. * Building the documentation:
  49. ===========================
  50. Run the python script doxybuild.py from the top directory:
  51. python doxybuild.py --open --with-dot
  52. See doxybuild.py --help for options.
  53. * Adding a reader/writer test:
  54. ============================
  55. To add a test, you need to create two files in test/data:
  56. - a TESTNAME.json file, that contains the input document in JSON format.
  57. - a TESTNAME.expected file, that contains a flatened representation of
  58. the input document.
  59. TESTNAME.expected file format:
  60. - each line represents a JSON element of the element tree represented
  61. by the input document.
  62. - each line has two parts: the path to access the element separated from
  63. the element value by '='. Array and object values are always empty
  64. (e.g. represented by either [] or {}).
  65. - element path: '.' represented the root element, and is used to separate
  66. object members. [N] is used to specify the value of an array element
  67. at index N.
  68. See test_complex_01.json and test_complex_01.expected to better understand
  69. element path.
  70. * Understanding reader/writer test output:
  71. ========================================
  72. When a test is run, output files are generated aside the input test files.
  73. Below is a short description of the content of each file:
  74. - test_complex_01.json: input JSON document
  75. - test_complex_01.expected: flattened JSON element tree used to check if
  76. parsing was corrected.
  77. - test_complex_01.actual: flattened JSON element tree produced by
  78. jsontest.exe from reading test_complex_01.json
  79. - test_complex_01.rewrite: JSON document written by jsontest.exe using the
  80. Json::Value parsed from test_complex_01.json and serialized using
  81. Json::StyledWritter.
  82. - test_complex_01.actual-rewrite: flattened JSON element tree produced by
  83. jsontest.exe from reading test_complex_01.rewrite.
  84. test_complex_01.process-output: jsontest.exe output, typically useful to
  85. understand parsing error.