├── AUTHORS ├── LICENSE ├── README.md ├── README.txt ├── SConstruct ├── bin └── linux-gcc-4.1.2 │ └── benchmark ├── buildscons └── linux-gcc-4.1.2 │ └── src │ └── benchmark │ ├── benchmark │ └── main.o ├── devtools ├── __init__.py ├── antglob.py ├── fixeol.py └── tarball.py ├── doc ├── doxyfile.in ├── footer.html ├── header.html ├── jsoncpp.dox ├── readme.txt └── roadmap.dox ├── doxybuild.py ├── include └── json │ ├── autolink.h │ ├── config.h │ ├── features.h │ ├── forwards.h │ ├── json.h │ ├── reader.h │ ├── value.h │ └── writer.h ├── install_depend_lib.sh ├── makefiles └── vs71 │ ├── jsoncpp.sln │ ├── jsontest.vcproj │ ├── lib_json.vcproj │ └── test_lib_json.vcproj ├── makerelease.py ├── scons-tools ├── globtool.py ├── globtool.pyc ├── srcdist.py ├── srcdist.pyc ├── substinfile.py ├── targz.py └── targz.pyc ├── src ├── benchmark │ └── main.cpp ├── jsontestrunner │ ├── main.cpp │ └── sconscript ├── lib_json │ ├── json_batchallocator.h │ ├── json_internalarray.inl │ ├── json_internalmap.inl │ ├── json_reader.cpp │ ├── json_value.cpp │ ├── json_valueiterator.inl │ ├── json_writer.cpp │ └── sconscript └── test_lib_json │ ├── jsontest.cpp │ ├── jsontest.h │ ├── main.cpp │ └── sconscript ├── test ├── cleantests.py ├── data │ ├── test_array_01.actual │ ├── test_array_01.actual-rewrite │ ├── test_array_01.expected │ ├── test_array_01.json │ ├── test_array_01.process-output │ ├── test_array_01.rewrite │ ├── test_array_02.actual │ ├── test_array_02.actual-rewrite │ ├── test_array_02.expected │ ├── test_array_02.json │ ├── test_array_02.process-output │ ├── test_array_02.rewrite │ ├── test_array_03.actual │ ├── test_array_03.actual-rewrite │ ├── test_array_03.expected │ ├── test_array_03.json │ ├── test_array_03.process-output │ ├── test_array_03.rewrite │ ├── test_array_04.actual │ ├── test_array_04.actual-rewrite │ ├── test_array_04.expected │ ├── test_array_04.json │ ├── test_array_04.process-output │ ├── test_array_04.rewrite │ ├── test_array_05.actual │ ├── test_array_05.actual-rewrite │ ├── test_array_05.expected │ ├── test_array_05.json │ ├── test_array_05.process-output │ ├── test_array_05.rewrite │ ├── test_array_06.actual │ ├── test_array_06.actual-rewrite │ ├── test_array_06.expected │ ├── test_array_06.json │ ├── test_array_06.process-output │ ├── test_array_06.rewrite │ ├── test_basic_01.actual │ ├── test_basic_01.actual-rewrite │ ├── test_basic_01.expected │ ├── test_basic_01.json │ ├── test_basic_01.process-output │ ├── test_basic_01.rewrite │ ├── test_basic_02.actual │ ├── test_basic_02.actual-rewrite │ ├── test_basic_02.expected │ ├── test_basic_02.json │ ├── test_basic_02.process-output │ ├── test_basic_02.rewrite │ ├── test_basic_03.actual │ ├── test_basic_03.actual-rewrite │ ├── test_basic_03.expected │ ├── test_basic_03.json │ ├── test_basic_03.process-output │ ├── test_basic_03.rewrite │ ├── test_basic_04.actual │ ├── test_basic_04.actual-rewrite │ ├── test_basic_04.expected │ ├── test_basic_04.json │ ├── test_basic_04.process-output │ ├── test_basic_04.rewrite │ ├── test_basic_05.actual │ ├── test_basic_05.actual-rewrite │ ├── test_basic_05.expected │ ├── test_basic_05.json │ ├── test_basic_05.process-output │ ├── test_basic_05.rewrite │ ├── test_basic_06.actual │ ├── test_basic_06.actual-rewrite │ ├── test_basic_06.expected │ ├── test_basic_06.json │ ├── test_basic_06.process-output │ ├── test_basic_06.rewrite │ ├── test_basic_07.actual │ ├── test_basic_07.actual-rewrite │ ├── test_basic_07.expected │ ├── test_basic_07.json │ ├── test_basic_07.process-output │ ├── test_basic_07.rewrite │ ├── test_basic_08.actual │ ├── test_basic_08.actual-rewrite │ ├── test_basic_08.expected │ ├── test_basic_08.json │ ├── test_basic_08.process-output │ ├── test_basic_08.rewrite │ ├── test_basic_09.actual │ ├── test_basic_09.actual-rewrite │ ├── test_basic_09.expected │ ├── test_basic_09.json │ ├── test_basic_09.process-output │ ├── test_basic_09.rewrite │ ├── test_comment_01.actual │ ├── test_comment_01.actual-rewrite │ ├── test_comment_01.expected │ ├── test_comment_01.json │ ├── test_comment_01.process-output │ ├── test_comment_01.rewrite │ ├── test_complex_01.actual │ ├── test_complex_01.actual-rewrite │ ├── test_complex_01.expected │ ├── test_complex_01.json │ ├── test_complex_01.process-output │ ├── test_complex_01.rewrite │ ├── test_integer_01.actual │ ├── test_integer_01.actual-rewrite │ ├── test_integer_01.expected │ ├── test_integer_01.json │ ├── test_integer_01.process-output │ ├── test_integer_01.rewrite │ ├── test_integer_02.actual │ ├── test_integer_02.actual-rewrite │ ├── test_integer_02.expected │ ├── test_integer_02.json │ ├── test_integer_02.process-output │ ├── test_integer_02.rewrite │ ├── test_integer_03.actual │ ├── test_integer_03.actual-rewrite │ ├── test_integer_03.expected │ ├── test_integer_03.json │ ├── test_integer_03.process-output │ ├── test_integer_03.rewrite │ ├── test_integer_04.actual │ ├── test_integer_04.actual-rewrite │ ├── test_integer_04.expected │ ├── test_integer_04.json │ ├── test_integer_04.process-output │ ├── test_integer_04.rewrite │ ├── test_integer_05.actual │ ├── test_integer_05.actual-rewrite │ ├── test_integer_05.expected │ ├── test_integer_05.json │ ├── test_integer_05.process-output │ ├── test_integer_05.rewrite │ ├── test_large_01.actual │ ├── test_large_01.actual-rewrite │ ├── test_large_01.expected │ ├── test_large_01.json │ ├── test_large_01.process-output │ ├── test_large_01.rewrite │ ├── test_object_01.actual │ ├── test_object_01.actual-rewrite │ ├── test_object_01.expected │ ├── test_object_01.json │ ├── test_object_01.process-output │ ├── test_object_01.rewrite │ ├── test_object_02.actual │ ├── test_object_02.actual-rewrite │ ├── test_object_02.expected │ ├── test_object_02.json │ ├── test_object_02.process-output │ ├── test_object_02.rewrite │ ├── test_object_03.actual │ ├── test_object_03.actual-rewrite │ ├── test_object_03.expected │ ├── test_object_03.json │ ├── test_object_03.process-output │ ├── test_object_03.rewrite │ ├── test_object_04.actual │ ├── test_object_04.actual-rewrite │ ├── test_object_04.expected │ ├── test_object_04.json │ ├── test_object_04.process-output │ ├── test_object_04.rewrite │ ├── test_preserve_comment_01.actual │ ├── test_preserve_comment_01.actual-rewrite │ ├── test_preserve_comment_01.expected │ ├── test_preserve_comment_01.json │ ├── test_preserve_comment_01.process-output │ ├── test_preserve_comment_01.rewrite │ ├── test_real_01.actual │ ├── test_real_01.actual-rewrite │ ├── test_real_01.expected │ ├── test_real_01.json │ ├── test_real_01.process-output │ ├── test_real_01.rewrite │ ├── test_real_02.actual │ ├── test_real_02.actual-rewrite │ ├── test_real_02.expected │ ├── test_real_02.json │ ├── test_real_02.process-output │ ├── test_real_02.rewrite │ ├── test_real_03.actual │ ├── test_real_03.actual-rewrite │ ├── test_real_03.expected │ ├── test_real_03.json │ ├── test_real_03.process-output │ ├── test_real_03.rewrite │ ├── test_real_04.actual │ ├── test_real_04.actual-rewrite │ ├── test_real_04.expected │ ├── test_real_04.json │ ├── test_real_04.process-output │ ├── test_real_04.rewrite │ ├── test_real_05.actual │ ├── test_real_05.actual-rewrite │ ├── test_real_05.expected │ ├── test_real_05.json │ ├── test_real_05.process-output │ ├── test_real_05.rewrite │ ├── test_real_06.actual │ ├── test_real_06.actual-rewrite │ ├── test_real_06.expected │ ├── test_real_06.json │ ├── test_real_06.process-output │ ├── test_real_06.rewrite │ ├── test_real_07.actual │ ├── test_real_07.actual-rewrite │ ├── test_real_07.expected │ ├── test_real_07.json │ ├── test_real_07.process-output │ ├── test_real_07.rewrite │ ├── test_string_01.actual │ ├── test_string_01.actual-rewrite │ ├── test_string_01.expected │ ├── test_string_01.json │ ├── test_string_01.process-output │ ├── test_string_01.rewrite │ ├── test_string_02.actual │ ├── test_string_02.actual-rewrite │ ├── test_string_02.expected │ ├── test_string_02.json │ ├── test_string_02.process-output │ ├── test_string_02.rewrite │ ├── test_string_unicode_01.actual │ ├── test_string_unicode_01.actual-rewrite │ ├── test_string_unicode_01.expected │ ├── test_string_unicode_01.json │ ├── test_string_unicode_01.process-output │ ├── test_string_unicode_01.rewrite │ ├── test_string_unicode_02.actual │ ├── test_string_unicode_02.actual-rewrite │ ├── test_string_unicode_02.expected │ ├── test_string_unicode_02.json │ ├── test_string_unicode_02.process-output │ ├── test_string_unicode_02.rewrite │ ├── test_string_unicode_03.actual │ ├── test_string_unicode_03.actual-rewrite │ ├── test_string_unicode_03.expected │ ├── test_string_unicode_03.json │ ├── test_string_unicode_03.process-output │ ├── test_string_unicode_03.rewrite │ ├── test_string_unicode_04.actual │ ├── test_string_unicode_04.actual-rewrite │ ├── test_string_unicode_04.expected │ ├── test_string_unicode_04.json │ ├── test_string_unicode_04.process-output │ ├── test_string_unicode_04.rewrite │ ├── test_string_unicode_05.actual │ ├── test_string_unicode_05.actual-rewrite │ ├── test_string_unicode_05.expected │ ├── test_string_unicode_05.json │ ├── test_string_unicode_05.process-output │ └── test_string_unicode_05.rewrite ├── generate_expected.py ├── jsonchecker │ ├── fail1.json │ ├── fail10.json │ ├── fail11.json │ ├── fail12.json │ ├── fail13.json │ ├── fail14.json │ ├── fail15.json │ ├── fail16.json │ ├── fail17.json │ ├── fail18.json │ ├── fail19.json │ ├── fail2.json │ ├── fail20.json │ ├── fail21.json │ ├── fail22.json │ ├── fail23.json │ ├── fail24.json │ ├── fail25.json │ ├── fail26.json │ ├── fail27.json │ ├── fail28.json │ ├── fail29.json │ ├── fail3.json │ ├── fail30.json │ ├── fail31.json │ ├── fail32.json │ ├── fail33.json │ ├── fail4.json │ ├── fail5.json │ ├── fail6.json │ ├── fail7.json │ ├── fail8.json │ ├── fail9.json │ ├── pass1.json │ ├── pass2.json │ ├── pass3.json │ └── readme.txt ├── pyjsontestrunner.py ├── runjsontests.py ├── runjsontests.pyc ├── rununittests.py └── rununittests.pyc └── version /AUTHORS: -------------------------------------------------------------------------------- 1 | Baptiste Lepilleur 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The json-cpp library and this documentation are in Public Domain. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 缘由 2 | 3 | JSON+UTF-8是一种非常好的组合,我们在后台服务器比较多地使用这种组合。[JsonCpp](http://jsoncpp.sourceforge.net/)是一个非常优秀的开源项目,代码非常简洁,使用方式也很直观。Google Chrome使用了JsonCpp。 4 | 5 | 我们在后台的服务器上使用JsonCpp生成json格式时,发现它的效率是有问题的。format 40KB的数据,平均耗时10ms。为了提高JsonCpp的writer性能,我们想了很多方法,做了一些优化,效果很明显。 6 | 7 | 本来是想将这些优化合并到trunk上,但是提交的patch很久都没有得到回复。我们注意到JsonCpp已经属于公共领域(LICENSE文件中有注明),于是我们想在github上fork一个项目出来,让更多的人受益。 8 | 9 | # 主要的改进点 10 | 11 | 1. SConstruct中将platform设置为'linux-gcc',并且设置'-O2'优化参数。这是最简单有效的优化方法,可惜很多人都不知道这点。 12 | 2. 增加Value::setValue接口,提高存入字符串类型的效率。 13 | 3. 优化JsonCpp对StaticString类型的处理,对StaticString类型不做深拷贝。 14 | 4. 优化valueToQuotedString函数,提高处理字符串类型的效率。 15 | 5. 优化FastWriter对objectValue类型的处理。 16 | 17 | # benchmark 18 | 19 | 我在src/benchmark目录下放置了一个测试程序,由于不是很懂scons,不知道怎么增加一个target,可以实现输入这条'scons benchmark'命令就可以运行一次。如果有熟悉scons的朋友可以帮我们搞一下。 20 | 21 | 使用JsonCpp官方的0.6.0rc2版本作对比,结果如下。数据是在一台装备Intel(R) Xeon(R) CPU E5420,Linux内核版本是2.6.18的服务器上得到的。在高并发的服务上运行,实际的性能差距还会更大。 22 | 23 | ``` 24 | 官方原版本: 10,781μs 25 | 官方-02优化版本: 6,950μs 26 | 本版本: 3,210μs 27 | ``` 28 | 29 | # 值得注意的几点 30 | 31 | 1. 尽量使用引用(可以参考benchmark例子的代码),否则JSON的层数越多,构造Value的开销越大。 32 | 2. 可以设计两个outfmt,'outfmt=json'调用FastWriter生成紧凑的JSON字符串;'outfmt=json2'调用StyledWriter生成美观对齐的JSON字符串以供调试。 33 | 34 | # 以后的计划 35 | 36 | 我们会不定期合并官方trunk上的新功能。 37 | 38 | # 一点建议 39 | 40 | 我们项目后来改用了rapidjson,性能比JsonCpp好太多,建议大家使用[rapidjson](https://code.google.com/p/rapidjson/)。 41 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | * Introduction: 2 | ============= 3 | 4 | JSON (JavaScript Object Notation) is a lightweight data-interchange format. 5 | It can represent integer, real number, string, an ordered sequence of 6 | value, and a collection of name/value pairs. 7 | 8 | JsonCpp is a simple API to manipulate JSON value, handle serialization 9 | and unserialization to string. 10 | 11 | It can also preserve existing comment in unserialization/serialization steps, 12 | making it a convenient format to store user input files. 13 | 14 | Unserialization parsing is user friendly and provides precise error reports. 15 | 16 | 17 | * Building/Testing: 18 | ================= 19 | 20 | JsonCpp uses Scons (http://www.scons.org) as a build system. Scons requires 21 | python to be installed (http://www.python.org). 22 | 23 | You download scons-local distribution from the following url: 24 | http://sourceforge.net/project/showfiles.php?group_id=30337&package_id=67375 25 | 26 | Unzip it in the directory where you found this README file. scons.py Should be 27 | at the same level as README. 28 | 29 | python scons.py platform=PLTFRM [TARGET] 30 | where PLTFRM may be one of: 31 | suncc Sun C++ (Solaris) 32 | vacpp Visual Age C++ (AIX) 33 | mingw 34 | msvc6 Microsoft Visual Studio 6 service pack 5-6 35 | msvc70 Microsoft Visual Studio 2002 36 | msvc71 Microsoft Visual Studio 2003 37 | msvc80 Microsoft Visual Studio 2005 38 | linux-gcc Gnu C++ (linux, also reported to work for Mac OS X) 39 | 40 | adding platform is fairly simple. You need to change the Sconstruct file 41 | to do so. 42 | 43 | and TARGET may be: 44 | check: build library and run unit tests. 45 | 46 | 47 | * Running the test manually: 48 | ========================== 49 | 50 | cd test 51 | # This will run the Reader/Writer tests 52 | python runjsontests.py "path to jsontest.exe" 53 | 54 | # This will run the Reader/Writer tests, using JSONChecker test suite 55 | # (http://www.json.org/JSON_checker/). 56 | # Notes: not all tests pass: JsonCpp is too lenient (for example, 57 | # it allows an integer to start with '0'). The goal is to improve 58 | # strict mode parsing to get all tests to pass. 59 | python runjsontests.py --with-json-checker "path to jsontest.exe" 60 | 61 | # This will run the unit tests (mostly Value) 62 | python rununittests.py "path to test_lib_json.exe" 63 | 64 | You can run the tests using valgrind: 65 | python rununittests.py --valgrind "path to test_lib_json.exe" 66 | 67 | 68 | * Building the documentation: 69 | =========================== 70 | 71 | Run the python script doxybuild.py from the top directory: 72 | 73 | python doxybuild.py --open --with-dot 74 | 75 | See doxybuild.py --help for options. 76 | 77 | 78 | * Adding a reader/writer test: 79 | ============================ 80 | 81 | To add a test, you need to create two files in test/data: 82 | - a TESTNAME.json file, that contains the input document in JSON format. 83 | - a TESTNAME.expected file, that contains a flatened representation of 84 | the input document. 85 | 86 | TESTNAME.expected file format: 87 | - each line represents a JSON element of the element tree represented 88 | by the input document. 89 | - each line has two parts: the path to access the element separated from 90 | the element value by '='. Array and object values are always empty 91 | (e.g. represented by either [] or {}). 92 | - element path: '.' represented the root element, and is used to separate 93 | object members. [N] is used to specify the value of an array element 94 | at index N. 95 | See test_complex_01.json and test_complex_01.expected to better understand 96 | element path. 97 | 98 | 99 | * Understanding reader/writer test output: 100 | ======================================== 101 | 102 | When a test is run, output files are generated aside the input test files. 103 | Below is a short description of the content of each file: 104 | 105 | - test_complex_01.json: input JSON document 106 | - test_complex_01.expected: flattened JSON element tree used to check if 107 | parsing was corrected. 108 | 109 | - test_complex_01.actual: flattened JSON element tree produced by 110 | jsontest.exe from reading test_complex_01.json 111 | - test_complex_01.rewrite: JSON document written by jsontest.exe using the 112 | Json::Value parsed from test_complex_01.json and serialized using 113 | Json::StyledWritter. 114 | - test_complex_01.actual-rewrite: flattened JSON element tree produced by 115 | jsontest.exe from reading test_complex_01.rewrite. 116 | test_complex_01.process-output: jsontest.exe output, typically useful to 117 | understand parsing error. 118 | -------------------------------------------------------------------------------- /bin/linux-gcc-4.1.2/benchmark: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/bin/linux-gcc-4.1.2/benchmark -------------------------------------------------------------------------------- /buildscons/linux-gcc-4.1.2/src/benchmark/benchmark: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/buildscons/linux-gcc-4.1.2/src/benchmark/benchmark -------------------------------------------------------------------------------- /buildscons/linux-gcc-4.1.2/src/benchmark/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/buildscons/linux-gcc-4.1.2/src/benchmark/main.o -------------------------------------------------------------------------------- /devtools/__init__.py: -------------------------------------------------------------------------------- 1 | # module 2 | -------------------------------------------------------------------------------- /devtools/antglob.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | # Baptiste Lepilleur, 2009 4 | 5 | from dircache import listdir 6 | import re 7 | import fnmatch 8 | import os.path 9 | 10 | 11 | # These fnmatch expressions are used by default to prune the directory tree 12 | # while doing the recursive traversal in the glob_impl method of glob function. 13 | prune_dirs = '.git .bzr .hg .svn _MTN _darcs CVS SCCS ' 14 | 15 | # These fnmatch expressions are used by default to exclude files and dirs 16 | # while doing the recursive traversal in the glob_impl method of glob function. 17 | ##exclude_pats = prune_pats + '*~ #*# .#* %*% ._* .gitignore .cvsignore vssver.scc .DS_Store'.split() 18 | 19 | # These ant_glob expressions are used by default to exclude files and dirs and also prune the directory tree 20 | # while doing the recursive traversal in the glob_impl method of glob function. 21 | default_excludes = ''' 22 | **/*~ 23 | **/#*# 24 | **/.#* 25 | **/%*% 26 | **/._* 27 | **/CVS 28 | **/CVS/** 29 | **/.cvsignore 30 | **/SCCS 31 | **/SCCS/** 32 | **/vssver.scc 33 | **/.svn 34 | **/.svn/** 35 | **/.git 36 | **/.git/** 37 | **/.gitignore 38 | **/.bzr 39 | **/.bzr/** 40 | **/.hg 41 | **/.hg/** 42 | **/_MTN 43 | **/_MTN/** 44 | **/_darcs 45 | **/_darcs/** 46 | **/.DS_Store ''' 47 | 48 | DIR = 1 49 | FILE = 2 50 | DIR_LINK = 4 51 | FILE_LINK = 8 52 | LINKS = DIR_LINK | FILE_LINK 53 | ALL_NO_LINK = DIR | FILE 54 | ALL = DIR | FILE | LINKS 55 | 56 | _ANT_RE = re.compile( r'(/\*\*/)|(\*\*/)|(/\*\*)|(\*)|(/)|([^\*/]*)' ) 57 | 58 | def ant_pattern_to_re( ant_pattern ): 59 | """Generates a regular expression from the ant pattern. 60 | Matching convention: 61 | **/a: match 'a', 'dir/a', 'dir1/dir2/a' 62 | a/**/b: match 'a/b', 'a/c/b', 'a/d/c/b' 63 | *.py: match 'script.py' but not 'a/script.py' 64 | """ 65 | rex = ['^'] 66 | next_pos = 0 67 | sep_rex = r'(?:/|%s)' % re.escape( os.path.sep ) 68 | ## print 'Converting', ant_pattern 69 | for match in _ANT_RE.finditer( ant_pattern ): 70 | ## print 'Matched', match.group() 71 | ## print match.start(0), next_pos 72 | if match.start(0) != next_pos: 73 | raise ValueError( "Invalid ant pattern" ) 74 | if match.group(1): # /**/ 75 | rex.append( sep_rex + '(?:.*%s)?' % sep_rex ) 76 | elif match.group(2): # **/ 77 | rex.append( '(?:.*%s)?' % sep_rex ) 78 | elif match.group(3): # /** 79 | rex.append( sep_rex + '.*' ) 80 | elif match.group(4): # * 81 | rex.append( '[^/%s]*' % re.escape(os.path.sep) ) 82 | elif match.group(5): # / 83 | rex.append( sep_rex ) 84 | else: # somepath 85 | rex.append( re.escape(match.group(6)) ) 86 | next_pos = match.end() 87 | rex.append('$') 88 | return re.compile( ''.join( rex ) ) 89 | 90 | def _as_list( l ): 91 | if isinstance(l, basestring): 92 | return l.split() 93 | return l 94 | 95 | def glob(dir_path, 96 | includes = '**/*', 97 | excludes = default_excludes, 98 | entry_type = FILE, 99 | prune_dirs = prune_dirs, 100 | max_depth = 25): 101 | include_filter = [ant_pattern_to_re(p) for p in _as_list(includes)] 102 | exclude_filter = [ant_pattern_to_re(p) for p in _as_list(excludes)] 103 | prune_dirs = [p.replace('/',os.path.sep) for p in _as_list(prune_dirs)] 104 | dir_path = dir_path.replace('/',os.path.sep) 105 | entry_type_filter = entry_type 106 | 107 | def is_pruned_dir( dir_name ): 108 | for pattern in prune_dirs: 109 | if fnmatch.fnmatch( dir_name, pattern ): 110 | return True 111 | return False 112 | 113 | def apply_filter( full_path, filter_rexs ): 114 | """Return True if at least one of the filter regular expression match full_path.""" 115 | for rex in filter_rexs: 116 | if rex.match( full_path ): 117 | return True 118 | return False 119 | 120 | def glob_impl( root_dir_path ): 121 | child_dirs = [root_dir_path] 122 | while child_dirs: 123 | dir_path = child_dirs.pop() 124 | for entry in listdir( dir_path ): 125 | full_path = os.path.join( dir_path, entry ) 126 | ## print 'Testing:', full_path, 127 | is_dir = os.path.isdir( full_path ) 128 | if is_dir and not is_pruned_dir( entry ): # explore child directory ? 129 | ## print '===> marked for recursion', 130 | child_dirs.append( full_path ) 131 | included = apply_filter( full_path, include_filter ) 132 | rejected = apply_filter( full_path, exclude_filter ) 133 | if not included or rejected: # do not include entry ? 134 | ## print '=> not included or rejected' 135 | continue 136 | link = os.path.islink( full_path ) 137 | is_file = os.path.isfile( full_path ) 138 | if not is_file and not is_dir: 139 | ## print '=> unknown entry type' 140 | continue 141 | if link: 142 | entry_type = is_file and FILE_LINK or DIR_LINK 143 | else: 144 | entry_type = is_file and FILE or DIR 145 | ## print '=> type: %d' % entry_type, 146 | if (entry_type & entry_type_filter) != 0: 147 | ## print ' => KEEP' 148 | yield os.path.join( dir_path, entry ) 149 | ## else: 150 | ## print ' => TYPE REJECTED' 151 | return list( glob_impl( dir_path ) ) 152 | 153 | 154 | if __name__ == "__main__": 155 | import unittest 156 | 157 | class AntPatternToRETest(unittest.TestCase): 158 | ## def test_conversion( self ): 159 | ## self.assertEqual( '^somepath$', ant_pattern_to_re( 'somepath' ).pattern ) 160 | 161 | def test_matching( self ): 162 | test_cases = [ ( 'path', 163 | ['path'], 164 | ['somepath', 'pathsuffix', '/path', '/path'] ), 165 | ( '*.py', 166 | ['source.py', 'source.ext.py', '.py'], 167 | ['path/source.py', '/.py', 'dir.py/z', 'z.pyc', 'z.c'] ), 168 | ( '**/path', 169 | ['path', '/path', '/a/path', 'c:/a/path', '/a/b/path', '//a/path', '/a/path/b/path'], 170 | ['path/', 'a/path/b', 'dir.py/z', 'somepath', 'pathsuffix', 'a/somepath'] ), 171 | ( 'path/**', 172 | ['path/a', 'path/path/a', 'path//'], 173 | ['path', 'somepath/a', 'a/path', 'a/path/a', 'pathsuffix/a'] ), 174 | ( '/**/path', 175 | ['/path', '/a/path', '/a/b/path/path', '/path/path'], 176 | ['path', 'path/', 'a/path', '/pathsuffix', '/somepath'] ), 177 | ( 'a/b', 178 | ['a/b'], 179 | ['somea/b', 'a/bsuffix', 'a/b/c'] ), 180 | ( '**/*.py', 181 | ['script.py', 'src/script.py', 'a/b/script.py', '/a/b/script.py'], 182 | ['script.pyc', 'script.pyo', 'a.py/b'] ), 183 | ( 'src/**/*.py', 184 | ['src/a.py', 'src/dir/a.py'], 185 | ['a/src/a.py', '/src/a.py'] ), 186 | ] 187 | for ant_pattern, accepted_matches, rejected_matches in list(test_cases): 188 | def local_path( paths ): 189 | return [ p.replace('/',os.path.sep) for p in paths ] 190 | test_cases.append( (ant_pattern, local_path(accepted_matches), local_path( rejected_matches )) ) 191 | for ant_pattern, accepted_matches, rejected_matches in test_cases: 192 | rex = ant_pattern_to_re( ant_pattern ) 193 | print 'ant_pattern:', ant_pattern, ' => ', rex.pattern 194 | for accepted_match in accepted_matches: 195 | print 'Accepted?:', accepted_match 196 | self.assert_( rex.match( accepted_match ) is not None ) 197 | for rejected_match in rejected_matches: 198 | print 'Rejected?:', rejected_match 199 | self.assert_( rex.match( rejected_match ) is None ) 200 | 201 | unittest.main() 202 | -------------------------------------------------------------------------------- /devtools/fixeol.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | 3 | def fix_source_eol( path, is_dry_run = True, verbose = True, eol = '\n' ): 4 | """Makes sure that all sources have the specified eol sequence (default: unix).""" 5 | if not os.path.isfile( path ): 6 | raise ValueError( 'Path "%s" is not a file' % path ) 7 | try: 8 | f = open(path, 'rb') 9 | except IOError, msg: 10 | print >> sys.stderr, "%s: I/O Error: %s" % (file, str(msg)) 11 | return False 12 | try: 13 | raw_lines = f.readlines() 14 | finally: 15 | f.close() 16 | fixed_lines = [line.rstrip('\r\n') + eol for line in raw_lines] 17 | if raw_lines != fixed_lines: 18 | print '%s =>' % path, 19 | if not is_dry_run: 20 | f = open(path, "wb") 21 | try: 22 | f.writelines(fixed_lines) 23 | finally: 24 | f.close() 25 | if verbose: 26 | print is_dry_run and ' NEED FIX' or ' FIXED' 27 | return True 28 | ## 29 | ## 30 | ## 31 | ##def _do_fix( is_dry_run = True ): 32 | ## from waftools import antglob 33 | ## python_sources = antglob.glob( '.', 34 | ## includes = '**/*.py **/wscript **/wscript_build', 35 | ## excludes = antglob.default_excludes + './waf.py', 36 | ## prune_dirs = antglob.prune_dirs + 'waf-* ./build' ) 37 | ## for path in python_sources: 38 | ## _fix_python_source( path, is_dry_run ) 39 | ## 40 | ## cpp_sources = antglob.glob( '.', 41 | ## includes = '**/*.cpp **/*.h **/*.inl', 42 | ## prune_dirs = antglob.prune_dirs + 'waf-* ./build' ) 43 | ## for path in cpp_sources: 44 | ## _fix_source_eol( path, is_dry_run ) 45 | ## 46 | ## 47 | ##def dry_fix(context): 48 | ## _do_fix( is_dry_run = True ) 49 | ## 50 | ##def fix(context): 51 | ## _do_fix( is_dry_run = False ) 52 | ## 53 | ##def shutdown(): 54 | ## pass 55 | ## 56 | ##def check(context): 57 | ## # Unit tests are run when "check" target is used 58 | ## ut = UnitTest.unit_test() 59 | ## ut.change_to_testfile_dir = True 60 | ## ut.want_to_see_test_output = True 61 | ## ut.want_to_see_test_error = True 62 | ## ut.run() 63 | ## ut.print_results() 64 | -------------------------------------------------------------------------------- /devtools/tarball.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | import gzip 3 | import tarfile 4 | 5 | TARGZ_DEFAULT_COMPRESSION_LEVEL = 9 6 | 7 | def make_tarball(tarball_path, sources, base_dir, prefix_dir=''): 8 | """Parameters: 9 | tarball_path: output path of the .tar.gz file 10 | sources: list of sources to include in the tarball, relative to the current directory 11 | base_dir: if a source file is in a sub-directory of base_dir, then base_dir is stripped 12 | from path in the tarball. 13 | prefix_dir: all files stored in the tarball be sub-directory of prefix_dir. Set to '' 14 | to make them child of root. 15 | """ 16 | base_dir = os.path.normpath( os.path.abspath( base_dir ) ) 17 | def archive_name( path ): 18 | """Makes path relative to base_dir.""" 19 | path = os.path.normpath( os.path.abspath( path ) ) 20 | common_path = os.path.commonprefix( (base_dir, path) ) 21 | archive_name = path[len(common_path):] 22 | if os.path.isabs( archive_name ): 23 | archive_name = archive_name[1:] 24 | return os.path.join( prefix_dir, archive_name ) 25 | def visit(tar, dirname, names): 26 | for name in names: 27 | path = os.path.join(dirname, name) 28 | if os.path.isfile(path): 29 | path_in_tar = archive_name(path) 30 | tar.add(path, path_in_tar ) 31 | compression = TARGZ_DEFAULT_COMPRESSION_LEVEL 32 | tar = tarfile.TarFile.gzopen( tarball_path, 'w', compresslevel=compression ) 33 | try: 34 | for source in sources: 35 | source_path = source 36 | if os.path.isdir( source ): 37 | os.path.walk(source_path, visit, tar) 38 | else: 39 | path_in_tar = archive_name(source_path) 40 | tar.add(source_path, path_in_tar ) # filename, arcname 41 | finally: 42 | tar.close() 43 | 44 | def decompress( tarball_path, base_dir ): 45 | """Decompress the gzipped tarball into directory base_dir. 46 | """ 47 | # !!! This class method is not documented in the online doc 48 | # nor is bz2open! 49 | tar = tarfile.TarFile.gzopen(tarball_path, mode='r') 50 | try: 51 | tar.extractall( base_dir ) 52 | finally: 53 | tar.close() 54 | -------------------------------------------------------------------------------- /doc/footer.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 10 | 13 | 15 | 19 | 20 |
5 | 6 | SourceForge Logo 9 | 11 | hosts this site. 12 | 14 | 16 | Send comments to:
17 | Json-cpp Developers 18 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /doc/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JsonCpp - JSON data format manipulation library 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 | 21 | 22 |
14 | 15 | JsonCpp project page 16 | 17 | 19 | JsonCpp home page 20 |
23 | 24 |
25 | -------------------------------------------------------------------------------- /doc/jsoncpp.dox: -------------------------------------------------------------------------------- 1 | /** 2 | \mainpage 3 | \section _intro Introduction 4 | 5 | JSON (JavaScript Object Notation) 6 | is a lightweight data-interchange format. 7 | It can represent integer, real number, string, an ordered sequence of value, and 8 | a collection of name/value pairs. 9 | 10 | Here is an example of JSON data: 11 | \verbatim 12 | // Configuration options 13 | { 14 | // Default encoding for text 15 | "encoding" : "UTF-8", 16 | 17 | // Plug-ins loaded at start-up 18 | "plug-ins" : [ 19 | "python", 20 | "c++", 21 | "ruby" 22 | ], 23 | 24 | // Tab indent size 25 | "indent" : { "length" : 3, "use_space" = true } 26 | } 27 | \endverbatim 28 | 29 | \section _features Features 30 | - read and write JSON document 31 | - attach C and C++ style comments to element during parsing 32 | - rewrite JSON document preserving original comments 33 | 34 | Notes: Comments used to be supported in JSON but where removed for 35 | portability (C like comments are not supported in Python). Since 36 | comments are useful in configuration/input file, this feature was 37 | preserved. 38 | 39 | \section _example Code example 40 | 41 | \code 42 | Json::Value root; // will contains the root value after parsing. 43 | Json::Reader reader; 44 | bool parsingSuccessful = reader.parse( config_doc, root ); 45 | if ( !parsingSuccessful ) 46 | { 47 | // report to the user the failure and their locations in the document. 48 | std::cout << "Failed to parse configuration\n" 49 | << reader.getFormatedErrorMessages(); 50 | return; 51 | } 52 | 53 | // Get the value of the member of root named 'encoding', return 'UTF-8' if there is no 54 | // such member. 55 | std::string encoding = root.get("encoding", "UTF-8" ).asString(); 56 | // Get the value of the member of root named 'encoding', return a 'null' value if 57 | // there is no such member. 58 | const Json::Value plugins = root["plug-ins"]; 59 | for ( int index = 0; index < plugins.size(); ++index ) // Iterates over the sequence elements. 60 | loadPlugIn( plugins[index].asString() ); 61 | 62 | setIndentLength( root["indent"].get("length", 3).asInt() ); 63 | setIndentUseSpace( root["indent"].get("use_space", true).asBool() ); 64 | 65 | // ... 66 | // At application shutdown to make the new configuration document: 67 | // Since Json::Value has implicit constructor for all value types, it is not 68 | // necessary to explicitly construct the Json::Value object: 69 | root["encoding"] = getCurrentEncoding(); 70 | root["indent"]["length"] = getCurrentIndentLength(); 71 | root["indent"]["use_space"] = getCurrentIndentUseSpace(); 72 | 73 | Json::StyledWriter writer; 74 | // Make a new JSON document for the configuration. Preserve original comments. 75 | std::string outputConfig = writer.write( root ); 76 | 77 | // You can also use streams. This will put the contents of any JSON 78 | // stream at a particular sub-value, if you'd like. 79 | std::cin >> root["subtree"]; 80 | 81 | // And you can write to a stream, using the StyledWriter automatically. 82 | std::cout << root; 83 | \endcode 84 | 85 | \section _plinks Build instructions 86 | The build instructions are located in the file 87 | README.txt in the top-directory of the project. 88 | 89 | Permanent link to the latest revision of the file in subversion: 90 | latest README.txt 91 | 92 | \section _pdownload Download 93 | The sources can be downloaded from 94 | SourceForge download page. 95 | 96 | The latest version of the source is available in the project's subversion repository: 97 | 98 | http://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/ 99 | 100 | To checkout the source, see the following 101 | instructions. 102 | 103 | \section _plinks Project links 104 | - json-cpp home 105 | - json-cpp sourceforge project 106 | 107 | \section _rlinks Related links 108 | - JSON Specification and alternate language implementations. 109 | - YAML A data format designed for human readability. 110 | - UTF-8 and Unicode FAQ. 111 | 112 | \section _license License 113 | The json-cpp library and this documentation are in Public Domain. 114 | 115 | \author Baptiste Lepilleur 116 | */ 117 | -------------------------------------------------------------------------------- /doc/readme.txt: -------------------------------------------------------------------------------- 1 | The documentation is generated using doxygen (http://www.doxygen.org). 2 | -------------------------------------------------------------------------------- /doc/roadmap.dox: -------------------------------------------------------------------------------- 1 | /*! \page roadmap JsonCpp roadmap 2 | \section ms_release Makes JsonCpp ready for release 3 | - Build system clean-up: 4 | - Fix build on Windows (shared-library build is broken) 5 | - Add enable/disable flag for static and shared library build 6 | - Enhance help 7 | - Platform portability check: (Notes: was ok on last check) 8 | - linux/gcc, 9 | - solaris/cc, 10 | - windows/msvc678, 11 | - aix/vacpp 12 | - Add JsonCpp version to header as numeric for use in preprocessor test 13 | - Remove buggy experimental hash stuff 14 | - Release on sourceforge download 15 | \section ms_strict Adds a strict mode to reader/parser 16 | Strict JSON support as specific in RFC 4627 (http://www.ietf.org/rfc/rfc4627.txt?number=4627). 17 | - Enforce only object or array as root element 18 | - Disable comment support 19 | - Get jsonchecker failing tests to pass in strict mode 20 | \section ms_separation Expose json reader/writer API that do not impose using Json::Value. 21 | Some typical use-case involve an application specific structure to/from a JSON document. 22 | - Event base parser to allow unserializing a Json document directly in datastructure instead of 23 | using the intermediate Json::Value. 24 | - "Stream" based parser to serialized a Json document without using Json::Value as input. 25 | - Performance oriented parser/writer: 26 | - Provides an event based parser. Should allow pulling & skipping events for ease of use. 27 | - Provides a JSON document builder: fast only. 28 | \section ms_perfo Performance tuning 29 | - Provides support for static property name definition avoiding allocation 30 | - Static property dictionnary can be provided to JSON reader 31 | - Performance scenario & benchmarking 32 | */ 33 | -------------------------------------------------------------------------------- /doxybuild.py: -------------------------------------------------------------------------------- 1 | """Script to generate doxygen documentation. 2 | """ 3 | 4 | import re 5 | import os 6 | import os.path 7 | import sys 8 | import shutil 9 | from devtools import tarball 10 | 11 | def find_program(*filenames): 12 | """find a program in folders path_lst, and sets env[var] 13 | @param filenames: a list of possible names of the program to search for 14 | @return: the full path of the filename if found, or '' if filename could not be found 15 | """ 16 | paths = os.environ.get('PATH', '').split(os.pathsep) 17 | suffixes = ('win32' in sys.platform ) and '.exe .com .bat .cmd' or '' 18 | for filename in filenames: 19 | for name in [filename+ext for ext in suffixes.split()]: 20 | for directory in paths: 21 | full_path = os.path.join(directory, name) 22 | if os.path.isfile(full_path): 23 | return full_path 24 | return '' 25 | 26 | def do_subst_in_file(targetfile, sourcefile, dict): 27 | """Replace all instances of the keys of dict with their values. 28 | For example, if dict is {'%VERSION%': '1.2345', '%BASE%': 'MyProg'}, 29 | then all instances of %VERSION% in the file will be replaced with 1.2345 etc. 30 | """ 31 | try: 32 | f = open(sourcefile, 'rb') 33 | contents = f.read() 34 | f.close() 35 | except: 36 | print "Can't read source file %s"%sourcefile 37 | raise 38 | for (k,v) in dict.items(): 39 | v = v.replace('\\','\\\\') 40 | contents = re.sub(k, v, contents) 41 | try: 42 | f = open(targetfile, 'wb') 43 | f.write(contents) 44 | f.close() 45 | except: 46 | print "Can't write target file %s"%targetfile 47 | raise 48 | 49 | def run_doxygen(doxygen_path, config_file, working_dir, is_silent): 50 | config_file = os.path.abspath( config_file ) 51 | doxygen_path = doxygen_path 52 | old_cwd = os.getcwd() 53 | try: 54 | os.chdir( working_dir ) 55 | cmd = [doxygen_path, config_file] 56 | print 'Running:', ' '.join( cmd ) 57 | try: 58 | import subprocess 59 | except: 60 | if os.system( ' '.join( cmd ) ) != 0: 61 | print 'Documentation generation failed' 62 | return False 63 | else: 64 | if is_silent: 65 | process = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) 66 | else: 67 | process = subprocess.Popen( cmd ) 68 | stdout, _ = process.communicate() 69 | if process.returncode: 70 | print 'Documentation generation failed:' 71 | print stdout 72 | return False 73 | return True 74 | finally: 75 | os.chdir( old_cwd ) 76 | 77 | def build_doc( options, make_release=False ): 78 | if make_release: 79 | options.make_tarball = True 80 | options.with_dot = True 81 | options.with_html_help = True 82 | options.with_uml_look = True 83 | options.open = False 84 | options.silent = True 85 | 86 | version = open('version','rt').read().strip() 87 | output_dir = 'dist/doxygen' # relative to doc/doxyfile location. 88 | if not os.path.isdir( output_dir ): 89 | os.makedirs( output_dir ) 90 | top_dir = os.path.abspath( '.' ) 91 | html_output_dirname = 'jsoncpp-api-html-' + version 92 | tarball_path = os.path.join( 'dist', html_output_dirname + '.tar.gz' ) 93 | warning_log_path = os.path.join( output_dir, '../jsoncpp-doxygen-warning.log' ) 94 | html_output_path = os.path.join( output_dir, html_output_dirname ) 95 | def yesno( bool ): 96 | return bool and 'YES' or 'NO' 97 | subst_keys = { 98 | '%JSONCPP_VERSION%': version, 99 | '%DOC_TOPDIR%': '', 100 | '%TOPDIR%': top_dir, 101 | '%HTML_OUTPUT%': os.path.join( '..', output_dir, html_output_dirname ), 102 | '%HAVE_DOT%': yesno(options.with_dot), 103 | '%DOT_PATH%': os.path.split(options.dot_path)[0], 104 | '%HTML_HELP%': yesno(options.with_html_help), 105 | '%UML_LOOK%': yesno(options.with_uml_look), 106 | '%WARNING_LOG_PATH%': os.path.join( '..', warning_log_path ) 107 | } 108 | 109 | if os.path.isdir( output_dir ): 110 | print 'Deleting directory:', output_dir 111 | shutil.rmtree( output_dir ) 112 | if not os.path.isdir( output_dir ): 113 | os.makedirs( output_dir ) 114 | 115 | do_subst_in_file( 'doc/doxyfile', 'doc/doxyfile.in', subst_keys ) 116 | ok = run_doxygen( options.doxygen_path, 'doc/doxyfile', 'doc', is_silent=options.silent ) 117 | if not options.silent: 118 | print open(warning_log_path, 'rb').read() 119 | index_path = os.path.abspath(os.path.join(subst_keys['%HTML_OUTPUT%'], 'index.html')) 120 | print 'Generated documentation can be found in:' 121 | print index_path 122 | if options.open: 123 | import webbrowser 124 | webbrowser.open( 'file://' + index_path ) 125 | if options.make_tarball: 126 | print 'Generating doc tarball to', tarball_path 127 | tarball_sources = [ 128 | output_dir, 129 | 'README.txt', 130 | 'version' 131 | ] 132 | tarball_basedir = os.path.join( output_dir, html_output_dirname ) 133 | tarball.make_tarball( tarball_path, tarball_sources, tarball_basedir, html_output_dirname ) 134 | return tarball_path, html_output_dirname 135 | 136 | def main(): 137 | usage = """%prog 138 | Generates doxygen documentation in build/doxygen. 139 | Optionaly makes a tarball of the documentation to dist/. 140 | 141 | Must be started in the project top directory. 142 | """ 143 | from optparse import OptionParser 144 | parser = OptionParser(usage=usage) 145 | parser.allow_interspersed_args = False 146 | parser.add_option('--with-dot', dest="with_dot", action='store_true', default=False, 147 | help="""Enable usage of DOT to generate collaboration diagram""") 148 | parser.add_option('--dot', dest="dot_path", action='store', default=find_program('dot'), 149 | help="""Path to GraphViz dot tool. Must be full qualified path. [Default: %default]""") 150 | parser.add_option('--doxygen', dest="doxygen_path", action='store', default=find_program('doxygen'), 151 | help="""Path to Doxygen tool. [Default: %default]""") 152 | parser.add_option('--with-html-help', dest="with_html_help", action='store_true', default=False, 153 | help="""Enable generation of Microsoft HTML HELP""") 154 | parser.add_option('--no-uml-look', dest="with_uml_look", action='store_false', default=True, 155 | help="""Generates DOT graph without UML look [Default: False]""") 156 | parser.add_option('--open', dest="open", action='store_true', default=False, 157 | help="""Open the HTML index in the web browser after generation""") 158 | parser.add_option('--tarball', dest="make_tarball", action='store_true', default=False, 159 | help="""Generates a tarball of the documentation in dist/ directory""") 160 | parser.add_option('-s', '--silent', dest="silent", action='store_true', default=False, 161 | help="""Hides doxygen output""") 162 | parser.enable_interspersed_args() 163 | options, args = parser.parse_args() 164 | build_doc( options ) 165 | 166 | if __name__ == '__main__': 167 | main() 168 | -------------------------------------------------------------------------------- /include/json/autolink.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_AUTOLINK_H_INCLUDED 2 | # define JSON_AUTOLINK_H_INCLUDED 3 | 4 | # include "config.h" 5 | 6 | # ifdef JSON_IN_CPPTL 7 | # include 8 | # endif 9 | 10 | # if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && !defined(JSON_IN_CPPTL) 11 | # define CPPTL_AUTOLINK_NAME "json" 12 | # undef CPPTL_AUTOLINK_DLL 13 | # ifdef JSON_DLL 14 | # define CPPTL_AUTOLINK_DLL 15 | # endif 16 | # include "autolink.h" 17 | # endif 18 | 19 | #endif // JSON_AUTOLINK_H_INCLUDED 20 | -------------------------------------------------------------------------------- /include/json/config.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_CONFIG_H_INCLUDED 2 | # define JSON_CONFIG_H_INCLUDED 3 | 4 | /// If defined, indicates that json library is embedded in CppTL library. 5 | //# define JSON_IN_CPPTL 1 6 | 7 | /// If defined, indicates that json may leverage CppTL library 8 | //# define JSON_USE_CPPTL 1 9 | /// If defined, indicates that cpptl vector based map should be used instead of std::map 10 | /// as Value container. 11 | //# define JSON_USE_CPPTL_SMALLMAP 1 12 | /// If defined, indicates that Json specific container should be used 13 | /// (hash table & simple deque container with customizable allocator). 14 | /// THIS FEATURE IS STILL EXPERIMENTAL! 15 | //# define JSON_VALUE_USE_INTERNAL_MAP 1 16 | /// Force usage of standard new/malloc based allocator instead of memory pool based allocator. 17 | /// The memory pools allocator used optimization (initializing Value and ValueInternalLink 18 | /// as if it was a POD) that may cause some validation tool to report errors. 19 | /// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined. 20 | //# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1 21 | 22 | /// If defined, indicates that Json use exception to report invalid type manipulation 23 | /// instead of C assert macro. 24 | # define JSON_USE_EXCEPTION 1 25 | 26 | # ifdef JSON_IN_CPPTL 27 | # include 28 | # ifndef JSON_USE_CPPTL 29 | # define JSON_USE_CPPTL 1 30 | # endif 31 | # endif 32 | 33 | # ifdef JSON_IN_CPPTL 34 | # define JSON_API CPPTL_API 35 | # elif defined(JSON_DLL_BUILD) 36 | # define JSON_API __declspec(dllexport) 37 | # elif defined(JSON_DLL) 38 | # define JSON_API __declspec(dllimport) 39 | # else 40 | # define JSON_API 41 | # endif 42 | 43 | #endif // JSON_CONFIG_H_INCLUDED 44 | -------------------------------------------------------------------------------- /include/json/features.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPTL_JSON_FEATURES_H_INCLUDED 2 | # define CPPTL_JSON_FEATURES_H_INCLUDED 3 | 4 | # include "forwards.h" 5 | 6 | namespace Json { 7 | 8 | /** \brief Configuration passed to reader and writer. 9 | * This configuration object can be used to force the Reader or Writer 10 | * to behave in a standard conforming way. 11 | */ 12 | class JSON_API Features 13 | { 14 | public: 15 | /** \brief A configuration that allows all features and assumes all strings are UTF-8. 16 | * - C & C++ comments are allowed 17 | * - Root object can be any JSON value 18 | * - Assumes Value strings are encoded in UTF-8 19 | */ 20 | static Features all(); 21 | 22 | /** \brief A configuration that is strictly compatible with the JSON specification. 23 | * - Comments are forbidden. 24 | * - Root object must be either an array or an object value. 25 | * - Assumes Value strings are encoded in UTF-8 26 | */ 27 | static Features strictMode(); 28 | 29 | /** \brief Initialize the configuration like JsonConfig::allFeatures; 30 | */ 31 | Features(); 32 | 33 | /// \c true if comments are allowed. Default: \c true. 34 | bool allowComments_; 35 | 36 | /// \c true if root must be either an array or an object value. Default: \c false. 37 | bool strictRoot_; 38 | }; 39 | 40 | } // namespace Json 41 | 42 | #endif // CPPTL_JSON_FEATURES_H_INCLUDED 43 | -------------------------------------------------------------------------------- /include/json/forwards.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_FORWARDS_H_INCLUDED 2 | # define JSON_FORWARDS_H_INCLUDED 3 | 4 | # include "config.h" 5 | 6 | namespace Json { 7 | 8 | // writer.h 9 | class FastWriter; 10 | class StyledWriter; 11 | 12 | // reader.h 13 | class Reader; 14 | 15 | // features.h 16 | class Features; 17 | 18 | // value.h 19 | typedef int Int; 20 | typedef unsigned int UInt; 21 | class StaticString; 22 | class Path; 23 | class PathArgument; 24 | class Value; 25 | class ValueIteratorBase; 26 | class ValueIterator; 27 | class ValueConstIterator; 28 | #ifdef JSON_VALUE_USE_INTERNAL_MAP 29 | class ValueAllocator; 30 | class ValueMapAllocator; 31 | class ValueInternalLink; 32 | class ValueInternalArray; 33 | class ValueInternalMap; 34 | #endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP 35 | 36 | } // namespace Json 37 | 38 | 39 | #endif // JSON_FORWARDS_H_INCLUDED 40 | -------------------------------------------------------------------------------- /include/json/json.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_JSON_H_INCLUDED 2 | # define JSON_JSON_H_INCLUDED 3 | 4 | # include "autolink.h" 5 | # include "value.h" 6 | # include "reader.h" 7 | # include "writer.h" 8 | # include "features.h" 9 | 10 | #endif // JSON_JSON_H_INCLUDED 11 | -------------------------------------------------------------------------------- /include/json/reader.h: -------------------------------------------------------------------------------- 1 | #ifndef CPPTL_JSON_READER_H_INCLUDED 2 | # define CPPTL_JSON_READER_H_INCLUDED 3 | 4 | # include "features.h" 5 | # include "value.h" 6 | # include 7 | # include 8 | # include 9 | # include 10 | 11 | namespace Json { 12 | 13 | /** \brief Unserialize a JSON document into a Value. 14 | * 15 | */ 16 | class JSON_API Reader 17 | { 18 | public: 19 | typedef char Char; 20 | typedef const Char *Location; 21 | 22 | /** \brief Constructs a Reader allowing all features 23 | * for parsing. 24 | */ 25 | Reader(); 26 | 27 | /** \brief Constructs a Reader allowing the specified feature set 28 | * for parsing. 29 | */ 30 | Reader( const Features &features ); 31 | 32 | /** \brief Read a Value from a JSON document. 33 | * \param document UTF-8 encoded string containing the document to read. 34 | * \param root [out] Contains the root value of the document if it was 35 | * successfully parsed. 36 | * \param collectComments \c true to collect comment and allow writing them back during 37 | * serialization, \c false to discard comments. 38 | * This parameter is ignored if Features::allowComments_ 39 | * is \c false. 40 | * \return \c true if the document was successfully parsed, \c false if an error occurred. 41 | */ 42 | bool parse( const std::string &document, 43 | Value &root, 44 | bool collectComments = true ); 45 | 46 | /** \brief Read a Value from a JSON document. 47 | * \param document UTF-8 encoded string containing the document to read. 48 | * \param root [out] Contains the root value of the document if it was 49 | * successfully parsed. 50 | * \param collectComments \c true to collect comment and allow writing them back during 51 | * serialization, \c false to discard comments. 52 | * This parameter is ignored if Features::allowComments_ 53 | * is \c false. 54 | * \return \c true if the document was successfully parsed, \c false if an error occurred. 55 | */ 56 | bool parse( const char *beginDoc, const char *endDoc, 57 | Value &root, 58 | bool collectComments = true ); 59 | 60 | /// \brief Parse from input stream. 61 | /// \see Json::operator>>(std::istream&, Json::Value&). 62 | bool parse( std::istream &is, 63 | Value &root, 64 | bool collectComments = true ); 65 | 66 | /** \brief Returns a user friendly string that list errors in the parsed document. 67 | * \return Formatted error message with the list of errors with their location in 68 | * the parsed document. An empty string is returned if no error occurred 69 | * during parsing. 70 | */ 71 | std::string getFormatedErrorMessages() const; 72 | 73 | private: 74 | enum TokenType 75 | { 76 | tokenEndOfStream = 0, 77 | tokenObjectBegin, 78 | tokenObjectEnd, 79 | tokenArrayBegin, 80 | tokenArrayEnd, 81 | tokenString, 82 | tokenNumber, 83 | tokenTrue, 84 | tokenFalse, 85 | tokenNull, 86 | tokenArraySeparator, 87 | tokenMemberSeparator, 88 | tokenComment, 89 | tokenError 90 | }; 91 | 92 | class Token 93 | { 94 | public: 95 | TokenType type_; 96 | Location start_; 97 | Location end_; 98 | }; 99 | 100 | class ErrorInfo 101 | { 102 | public: 103 | Token token_; 104 | std::string message_; 105 | Location extra_; 106 | }; 107 | 108 | typedef std::deque Errors; 109 | 110 | bool expectToken( TokenType type, Token &token, const char *message ); 111 | bool readToken( Token &token ); 112 | void skipSpaces(); 113 | bool match( Location pattern, 114 | int patternLength ); 115 | bool readComment(); 116 | bool readCStyleComment(); 117 | bool readCppStyleComment(); 118 | bool readString(); 119 | void readNumber(); 120 | bool readValue(); 121 | bool readObject( Token &token ); 122 | bool readArray( Token &token ); 123 | bool decodeNumber( Token &token ); 124 | bool decodeString( Token &token ); 125 | bool decodeString( Token &token, std::string &decoded ); 126 | bool decodeDouble( Token &token ); 127 | bool decodeUnicodeCodePoint( Token &token, 128 | Location ¤t, 129 | Location end, 130 | unsigned int &unicode ); 131 | bool decodeUnicodeEscapeSequence( Token &token, 132 | Location ¤t, 133 | Location end, 134 | unsigned int &unicode ); 135 | bool addError( const std::string &message, 136 | Token &token, 137 | Location extra = 0 ); 138 | bool recoverFromError( TokenType skipUntilToken ); 139 | bool addErrorAndRecover( const std::string &message, 140 | Token &token, 141 | TokenType skipUntilToken ); 142 | void skipUntilSpace(); 143 | Value ¤tValue(); 144 | Char getNextChar(); 145 | void getLocationLineAndColumn( Location location, 146 | int &line, 147 | int &column ) const; 148 | std::string getLocationLineAndColumn( Location location ) const; 149 | void addComment( Location begin, 150 | Location end, 151 | CommentPlacement placement ); 152 | void skipCommentTokens( Token &token ); 153 | 154 | typedef std::stack Nodes; 155 | Nodes nodes_; 156 | Errors errors_; 157 | std::string document_; 158 | Location begin_; 159 | Location end_; 160 | Location current_; 161 | Location lastValueEnd_; 162 | Value *lastValue_; 163 | std::string commentsBefore_; 164 | Features features_; 165 | bool collectComments_; 166 | }; 167 | 168 | /** \brief Read from 'sin' into 'root'. 169 | 170 | Always keep comments from the input JSON. 171 | 172 | This can be used to read a file into a particular sub-object. 173 | For example: 174 | \code 175 | Json::Value root; 176 | cin >> root["dir"]["file"]; 177 | cout << root; 178 | \endcode 179 | Result: 180 | \verbatim 181 | { 182 | "dir": { 183 | "file": { 184 | // The input stream JSON would be nested here. 185 | } 186 | } 187 | } 188 | \endverbatim 189 | \throw std::exception on parse error. 190 | \see Json::operator<<() 191 | */ 192 | std::istream& operator>>( std::istream&, Value& ); 193 | 194 | } // namespace Json 195 | 196 | #endif // CPPTL_JSON_READER_H_INCLUDED 197 | -------------------------------------------------------------------------------- /include/json/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_WRITER_H_INCLUDED 2 | # define JSON_WRITER_H_INCLUDED 3 | 4 | # include "value.h" 5 | # include 6 | # include 7 | # include 8 | 9 | namespace Json { 10 | 11 | class Value; 12 | 13 | /** \brief Abstract class for writers. 14 | */ 15 | class JSON_API Writer 16 | { 17 | public: 18 | virtual ~Writer(); 19 | 20 | virtual std::string write( const Value &root ) = 0; 21 | }; 22 | 23 | /** \brief Outputs a Value in JSON format without formatting (not human friendly). 24 | * 25 | * The JSON document is written in a single line. It is not intended for 'human' consumption, 26 | * but may be usefull to support feature such as RPC where bandwith is limited. 27 | * \sa Reader, Value 28 | */ 29 | class JSON_API FastWriter : public Writer 30 | { 31 | public: 32 | FastWriter(); 33 | virtual ~FastWriter(){} 34 | 35 | void enableYAMLCompatibility(); 36 | 37 | public: // overridden from Writer 38 | virtual std::string write( const Value &root ); 39 | 40 | private: 41 | void writeValue( const Value &value ); 42 | 43 | std::string document_; 44 | bool yamlCompatiblityEnabled_; 45 | }; 46 | 47 | /** \brief Writes a Value in JSON format in a human friendly way. 48 | * 49 | * The rules for line break and indent are as follow: 50 | * - Object value: 51 | * - if empty then print {} without indent and line break 52 | * - if not empty the print '{', line break & indent, print one value per line 53 | * and then unindent and line break and print '}'. 54 | * - Array value: 55 | * - if empty then print [] without indent and line break 56 | * - if the array contains no object value, empty array or some other value types, 57 | * and all the values fit on one lines, then print the array on a single line. 58 | * - otherwise, it the values do not fit on one line, or the array contains 59 | * object or non empty array, then print one value per line. 60 | * 61 | * If the Value have comments then they are outputed according to their #CommentPlacement. 62 | * 63 | * \sa Reader, Value, Value::setComment() 64 | */ 65 | class JSON_API StyledWriter: public Writer 66 | { 67 | public: 68 | StyledWriter(); 69 | virtual ~StyledWriter(){} 70 | 71 | public: // overridden from Writer 72 | /** \brief Serialize a Value in JSON format. 73 | * \param root Value to serialize. 74 | * \return String containing the JSON document that represents the root value. 75 | */ 76 | virtual std::string write( const Value &root ); 77 | 78 | private: 79 | void writeValue( const Value &value ); 80 | void writeArrayValue( const Value &value ); 81 | bool isMultineArray( const Value &value ); 82 | void pushValue( const std::string &value ); 83 | void writeIndent(); 84 | void writeWithIndent( const std::string &value ); 85 | void indent(); 86 | void unindent(); 87 | void writeCommentBeforeValue( const Value &root ); 88 | void writeCommentAfterValueOnSameLine( const Value &root ); 89 | bool hasCommentForValue( const Value &value ); 90 | static std::string normalizeEOL( const std::string &text ); 91 | 92 | typedef std::vector ChildValues; 93 | 94 | ChildValues childValues_; 95 | std::string document_; 96 | std::string indentString_; 97 | int rightMargin_; 98 | int indentSize_; 99 | bool addChildValues_; 100 | }; 101 | 102 | /** \brief Writes a Value in JSON format in a human friendly way, 103 | to a stream rather than to a string. 104 | * 105 | * The rules for line break and indent are as follow: 106 | * - Object value: 107 | * - if empty then print {} without indent and line break 108 | * - if not empty the print '{', line break & indent, print one value per line 109 | * and then unindent and line break and print '}'. 110 | * - Array value: 111 | * - if empty then print [] without indent and line break 112 | * - if the array contains no object value, empty array or some other value types, 113 | * and all the values fit on one lines, then print the array on a single line. 114 | * - otherwise, it the values do not fit on one line, or the array contains 115 | * object or non empty array, then print one value per line. 116 | * 117 | * If the Value have comments then they are outputed according to their #CommentPlacement. 118 | * 119 | * \param indentation Each level will be indented by this amount extra. 120 | * \sa Reader, Value, Value::setComment() 121 | */ 122 | class JSON_API StyledStreamWriter 123 | { 124 | public: 125 | StyledStreamWriter( std::string indentation="\t" ); 126 | ~StyledStreamWriter(){} 127 | 128 | public: 129 | /** \brief Serialize a Value in JSON format. 130 | * \param out Stream to write to. (Can be ostringstream, e.g.) 131 | * \param root Value to serialize. 132 | * \note There is no point in deriving from Writer, since write() should not return a value. 133 | */ 134 | void write( std::ostream &out, const Value &root ); 135 | 136 | private: 137 | void writeValue( const Value &value ); 138 | void writeArrayValue( const Value &value ); 139 | bool isMultineArray( const Value &value ); 140 | void pushValue( const std::string &value ); 141 | void writeIndent(); 142 | void writeWithIndent( const std::string &value ); 143 | void indent(); 144 | void unindent(); 145 | void writeCommentBeforeValue( const Value &root ); 146 | void writeCommentAfterValueOnSameLine( const Value &root ); 147 | bool hasCommentForValue( const Value &value ); 148 | static std::string normalizeEOL( const std::string &text ); 149 | 150 | typedef std::vector ChildValues; 151 | 152 | ChildValues childValues_; 153 | std::ostream* document_; 154 | std::string indentString_; 155 | int rightMargin_; 156 | std::string indentation_; 157 | bool addChildValues_; 158 | }; 159 | 160 | std::string JSON_API valueToString( Int value ); 161 | std::string JSON_API valueToString( UInt value ); 162 | std::string JSON_API valueToString( double value ); 163 | std::string JSON_API valueToString( bool value ); 164 | std::string JSON_API valueToQuotedString( const char *value, std::string* document = NULL ); 165 | 166 | /// \brief Output using the StyledStreamWriter. 167 | /// \see Json::operator>>() 168 | std::ostream& operator<<( std::ostream&, const Value &root ); 169 | 170 | } // namespace Json 171 | 172 | 173 | 174 | #endif // JSON_WRITER_H_INCLUDED 175 | -------------------------------------------------------------------------------- /install_depend_lib.sh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/install_depend_lib.sh -------------------------------------------------------------------------------- /makefiles/vs71/jsoncpp.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_json", "lib_json.vcproj", "{B84F7231-16CE-41D8-8C08-7B523FF4225B}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsontest", "jsontest.vcproj", "{25AF2DD2-D396-4668-B188-488C33B8E620}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_lib_json", "test_lib_json.vcproj", "{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}" 12 | ProjectSection(ProjectDependencies) = postProject 13 | {B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B} 14 | EndProjectSection 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfiguration) = preSolution 18 | Debug = Debug 19 | dummy = dummy 20 | Release = Release 21 | EndGlobalSection 22 | GlobalSection(ProjectConfiguration) = postSolution 23 | {B84F7231-16CE-41D8-8C08-7B523FF4225B}.Debug.ActiveCfg = Debug|Win32 24 | {B84F7231-16CE-41D8-8C08-7B523FF4225B}.Debug.Build.0 = Debug|Win32 25 | {B84F7231-16CE-41D8-8C08-7B523FF4225B}.dummy.ActiveCfg = dummy|Win32 26 | {B84F7231-16CE-41D8-8C08-7B523FF4225B}.dummy.Build.0 = dummy|Win32 27 | {B84F7231-16CE-41D8-8C08-7B523FF4225B}.Release.ActiveCfg = Release|Win32 28 | {B84F7231-16CE-41D8-8C08-7B523FF4225B}.Release.Build.0 = Release|Win32 29 | {25AF2DD2-D396-4668-B188-488C33B8E620}.Debug.ActiveCfg = Debug|Win32 30 | {25AF2DD2-D396-4668-B188-488C33B8E620}.Debug.Build.0 = Debug|Win32 31 | {25AF2DD2-D396-4668-B188-488C33B8E620}.dummy.ActiveCfg = Debug|Win32 32 | {25AF2DD2-D396-4668-B188-488C33B8E620}.dummy.Build.0 = Debug|Win32 33 | {25AF2DD2-D396-4668-B188-488C33B8E620}.Release.ActiveCfg = Release|Win32 34 | {25AF2DD2-D396-4668-B188-488C33B8E620}.Release.Build.0 = Release|Win32 35 | {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug.ActiveCfg = Debug|Win32 36 | {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug.Build.0 = Debug|Win32 37 | {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.dummy.ActiveCfg = Debug|Win32 38 | {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.dummy.Build.0 = Debug|Win32 39 | {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release.ActiveCfg = Release|Win32 40 | {B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release.Build.0 = Release|Win32 41 | EndGlobalSection 42 | GlobalSection(ExtensibilityGlobals) = postSolution 43 | EndGlobalSection 44 | GlobalSection(ExtensibilityAddIns) = postSolution 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /makefiles/vs71/jsontest.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 31 | 33 | 41 | 43 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 62 | 68 | 77 | 79 | 88 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 109 | 110 | 111 | 112 | 113 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /makefiles/vs71/lib_json.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 36 | 38 | 41 | 43 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 60 | 67 | 84 | 86 | 89 | 91 | 93 | 95 | 97 | 99 | 101 | 103 | 105 | 107 | 108 | 115 | 132 | 134 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 161 | 162 | 163 | 164 | 165 | 166 | 168 | 169 | 171 | 172 | 174 | 175 | 177 | 178 | 180 | 181 | 183 | 184 | 186 | 187 | 189 | 190 | 192 | 193 | 195 | 196 | 198 | 199 | 201 | 202 | 204 | 205 | 207 | 208 | 210 | 211 | 212 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /makefiles/vs71/test_lib_json.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 12 | 13 | 14 | 20 | 32 | 34 | 42 | 44 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 65 | 71 | 80 | 82 | 91 | 93 | 97 | 99 | 101 | 103 | 105 | 107 | 109 | 111 | 113 | 114 | 115 | 116 | 117 | 118 | 120 | 121 | 123 | 124 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /scons-tools/globtool.py: -------------------------------------------------------------------------------- 1 | import fnmatch 2 | import os 3 | 4 | def generate( env ): 5 | def Glob( env, includes = None, excludes = None, dir = '.' ): 6 | """Adds Glob( includes = Split( '*' ), excludes = None, dir = '.') 7 | helper function to environment. 8 | 9 | Glob both the file-system files. 10 | 11 | includes: list of file name pattern included in the return list when matched. 12 | excludes: list of file name pattern exluced from the return list. 13 | 14 | Example: 15 | sources = env.Glob( ("*.cpp", '*.h'), "~*.cpp", "#src" ) 16 | """ 17 | def filterFilename(path): 18 | abs_path = os.path.join( dir, path ) 19 | if not os.path.isfile(abs_path): 20 | return 0 21 | fn = os.path.basename(path) 22 | match = 0 23 | for include in includes: 24 | if fnmatch.fnmatchcase( fn, include ): 25 | match = 1 26 | break 27 | if match == 1 and not excludes is None: 28 | for exclude in excludes: 29 | if fnmatch.fnmatchcase( fn, exclude ): 30 | match = 0 31 | break 32 | return match 33 | if includes is None: 34 | includes = ('*',) 35 | elif type(includes) in ( type(''), type(u'') ): 36 | includes = (includes,) 37 | if type(excludes) in ( type(''), type(u'') ): 38 | excludes = (excludes,) 39 | dir = env.Dir(dir).abspath 40 | paths = os.listdir( dir ) 41 | def makeAbsFileNode( path ): 42 | return env.File( os.path.join( dir, path ) ) 43 | nodes = filter( filterFilename, paths ) 44 | return map( makeAbsFileNode, nodes ) 45 | 46 | from SCons.Script import Environment 47 | Environment.Glob = Glob 48 | 49 | def exists(env): 50 | """ 51 | Tool always exists. 52 | """ 53 | return True 54 | -------------------------------------------------------------------------------- /scons-tools/globtool.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/scons-tools/globtool.pyc -------------------------------------------------------------------------------- /scons-tools/srcdist.py: -------------------------------------------------------------------------------- 1 | import os 2 | import os.path 3 | from fnmatch import fnmatch 4 | import targz 5 | 6 | ##def DoxyfileParse(file_contents): 7 | ## """ 8 | ## Parse a Doxygen source file and return a dictionary of all the values. 9 | ## Values will be strings and lists of strings. 10 | ## """ 11 | ## data = {} 12 | ## 13 | ## import shlex 14 | ## lex = shlex.shlex(instream = file_contents, posix = True) 15 | ## lex.wordchars += "*+./-:" 16 | ## lex.whitespace = lex.whitespace.replace("\n", "") 17 | ## lex.escape = "" 18 | ## 19 | ## lineno = lex.lineno 20 | ## last_backslash_lineno = lineno 21 | ## token = lex.get_token() 22 | ## key = token # the first token should be a key 23 | ## last_token = "" 24 | ## key_token = False 25 | ## next_key = False 26 | ## new_data = True 27 | ## 28 | ## def append_data(data, key, new_data, token): 29 | ## if new_data or len(data[key]) == 0: 30 | ## data[key].append(token) 31 | ## else: 32 | ## data[key][-1] += token 33 | ## 34 | ## while token: 35 | ## if token in ['\n']: 36 | ## if last_token not in ['\\']: 37 | ## key_token = True 38 | ## elif token in ['\\']: 39 | ## pass 40 | ## elif key_token: 41 | ## key = token 42 | ## key_token = False 43 | ## else: 44 | ## if token == "+=": 45 | ## if not data.has_key(key): 46 | ## data[key] = list() 47 | ## elif token == "=": 48 | ## data[key] = list() 49 | ## else: 50 | ## append_data( data, key, new_data, token ) 51 | ## new_data = True 52 | ## 53 | ## last_token = token 54 | ## token = lex.get_token() 55 | ## 56 | ## if last_token == '\\' and token != '\n': 57 | ## new_data = False 58 | ## append_data( data, key, new_data, '\\' ) 59 | ## 60 | ## # compress lists of len 1 into single strings 61 | ## for (k, v) in data.items(): 62 | ## if len(v) == 0: 63 | ## data.pop(k) 64 | ## 65 | ## # items in the following list will be kept as lists and not converted to strings 66 | ## if k in ["INPUT", "FILE_PATTERNS", "EXCLUDE_PATTERNS"]: 67 | ## continue 68 | ## 69 | ## if len(v) == 1: 70 | ## data[k] = v[0] 71 | ## 72 | ## return data 73 | ## 74 | ##def DoxySourceScan(node, env, path): 75 | ## """ 76 | ## Doxygen Doxyfile source scanner. This should scan the Doxygen file and add 77 | ## any files used to generate docs to the list of source files. 78 | ## """ 79 | ## default_file_patterns = [ 80 | ## '*.c', '*.cc', '*.cxx', '*.cpp', '*.c++', '*.java', '*.ii', '*.ixx', 81 | ## '*.ipp', '*.i++', '*.inl', '*.h', '*.hh ', '*.hxx', '*.hpp', '*.h++', 82 | ## '*.idl', '*.odl', '*.cs', '*.php', '*.php3', '*.inc', '*.m', '*.mm', 83 | ## '*.py', 84 | ## ] 85 | ## 86 | ## default_exclude_patterns = [ 87 | ## '*~', 88 | ## ] 89 | ## 90 | ## sources = [] 91 | ## 92 | ## data = DoxyfileParse(node.get_contents()) 93 | ## 94 | ## if data.get("RECURSIVE", "NO") == "YES": 95 | ## recursive = True 96 | ## else: 97 | ## recursive = False 98 | ## 99 | ## file_patterns = data.get("FILE_PATTERNS", default_file_patterns) 100 | ## exclude_patterns = data.get("EXCLUDE_PATTERNS", default_exclude_patterns) 101 | ## 102 | ## for node in data.get("INPUT", []): 103 | ## if os.path.isfile(node): 104 | ## sources.add(node) 105 | ## elif os.path.isdir(node): 106 | ## if recursive: 107 | ## for root, dirs, files in os.walk(node): 108 | ## for f in files: 109 | ## filename = os.path.join(root, f) 110 | ## 111 | ## pattern_check = reduce(lambda x, y: x or bool(fnmatch(filename, y)), file_patterns, False) 112 | ## exclude_check = reduce(lambda x, y: x and fnmatch(filename, y), exclude_patterns, True) 113 | ## 114 | ## if pattern_check and not exclude_check: 115 | ## sources.append(filename) 116 | ## else: 117 | ## for pattern in file_patterns: 118 | ## sources.extend(glob.glob("/".join([node, pattern]))) 119 | ## sources = map( lambda path: env.File(path), sources ) 120 | ## return sources 121 | ## 122 | ## 123 | ##def DoxySourceScanCheck(node, env): 124 | ## """Check if we should scan this file""" 125 | ## return os.path.isfile(node.path) 126 | 127 | def srcDistEmitter(source, target, env): 128 | ## """Doxygen Doxyfile emitter""" 129 | ## # possible output formats and their default values and output locations 130 | ## output_formats = { 131 | ## "HTML": ("YES", "html"), 132 | ## "LATEX": ("YES", "latex"), 133 | ## "RTF": ("NO", "rtf"), 134 | ## "MAN": ("YES", "man"), 135 | ## "XML": ("NO", "xml"), 136 | ## } 137 | ## 138 | ## data = DoxyfileParse(source[0].get_contents()) 139 | ## 140 | ## targets = [] 141 | ## out_dir = data.get("OUTPUT_DIRECTORY", ".") 142 | ## 143 | ## # add our output locations 144 | ## for (k, v) in output_formats.items(): 145 | ## if data.get("GENERATE_" + k, v[0]) == "YES": 146 | ## targets.append(env.Dir( os.path.join(out_dir, data.get(k + "_OUTPUT", v[1]))) ) 147 | ## 148 | ## # don't clobber targets 149 | ## for node in targets: 150 | ## env.Precious(node) 151 | ## 152 | ## # set up cleaning stuff 153 | ## for node in targets: 154 | ## env.Clean(node, node) 155 | ## 156 | ## return (targets, source) 157 | return (target,source) 158 | 159 | def generate(env): 160 | """ 161 | Add builders and construction variables for the 162 | SrcDist tool. 163 | """ 164 | ## doxyfile_scanner = env.Scanner( 165 | ## DoxySourceScan, 166 | ## "DoxySourceScan", 167 | ## scan_check = DoxySourceScanCheck, 168 | ## ) 169 | 170 | if targz.exists(env): 171 | srcdist_builder = targz.makeBuilder( srcDistEmitter ) 172 | 173 | env['BUILDERS']['SrcDist'] = srcdist_builder 174 | 175 | def exists(env): 176 | """ 177 | Make sure srcdist exists. 178 | """ 179 | return targz.exists(env) 180 | -------------------------------------------------------------------------------- /scons-tools/srcdist.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/scons-tools/srcdist.pyc -------------------------------------------------------------------------------- /scons-tools/substinfile.py: -------------------------------------------------------------------------------- 1 | import re 2 | from SCons.Script import * # the usual scons stuff you get in a SConscript 3 | 4 | def generate(env): 5 | """ 6 | Add builders and construction variables for the 7 | SubstInFile tool. 8 | 9 | Adds SubstInFile builder, which substitutes the keys->values of SUBST_DICT 10 | from the source to the target. 11 | The values of SUBST_DICT first have any construction variables expanded 12 | (its keys are not expanded). 13 | If a value of SUBST_DICT is a python callable function, it is called and 14 | the result is expanded as the value. 15 | If there's more than one source and more than one target, each target gets 16 | substituted from the corresponding source. 17 | """ 18 | def do_subst_in_file(targetfile, sourcefile, dict): 19 | """Replace all instances of the keys of dict with their values. 20 | For example, if dict is {'%VERSION%': '1.2345', '%BASE%': 'MyProg'}, 21 | then all instances of %VERSION% in the file will be replaced with 1.2345 etc. 22 | """ 23 | try: 24 | f = open(sourcefile, 'rb') 25 | contents = f.read() 26 | f.close() 27 | except: 28 | raise SCons.Errors.UserError, "Can't read source file %s"%sourcefile 29 | for (k,v) in dict.items(): 30 | contents = re.sub(k, v, contents) 31 | try: 32 | f = open(targetfile, 'wb') 33 | f.write(contents) 34 | f.close() 35 | except: 36 | raise SCons.Errors.UserError, "Can't write target file %s"%targetfile 37 | return 0 # success 38 | 39 | def subst_in_file(target, source, env): 40 | if not env.has_key('SUBST_DICT'): 41 | raise SCons.Errors.UserError, "SubstInFile requires SUBST_DICT to be set." 42 | d = dict(env['SUBST_DICT']) # copy it 43 | for (k,v) in d.items(): 44 | if callable(v): 45 | d[k] = env.subst(v()).replace('\\','\\\\') 46 | elif SCons.Util.is_String(v): 47 | d[k] = env.subst(v).replace('\\','\\\\') 48 | else: 49 | raise SCons.Errors.UserError, "SubstInFile: key %s: %s must be a string or callable"%(k, repr(v)) 50 | for (t,s) in zip(target, source): 51 | return do_subst_in_file(str(t), str(s), d) 52 | 53 | def subst_in_file_string(target, source, env): 54 | """This is what gets printed on the console.""" 55 | return '\n'.join(['Substituting vars from %s into %s'%(str(s), str(t)) 56 | for (t,s) in zip(target, source)]) 57 | 58 | def subst_emitter(target, source, env): 59 | """Add dependency from substituted SUBST_DICT to target. 60 | Returns original target, source tuple unchanged. 61 | """ 62 | d = env['SUBST_DICT'].copy() # copy it 63 | for (k,v) in d.items(): 64 | if callable(v): 65 | d[k] = env.subst(v()) 66 | elif SCons.Util.is_String(v): 67 | d[k]=env.subst(v) 68 | Depends(target, SCons.Node.Python.Value(d)) 69 | return target, source 70 | 71 | ## env.Append(TOOLS = 'substinfile') # this should be automaticaly done by Scons ?!? 72 | subst_action = SCons.Action.Action( subst_in_file, subst_in_file_string ) 73 | env['BUILDERS']['SubstInFile'] = Builder(action=subst_action, emitter=subst_emitter) 74 | 75 | def exists(env): 76 | """ 77 | Make sure tool exists. 78 | """ 79 | return True 80 | -------------------------------------------------------------------------------- /scons-tools/targz.py: -------------------------------------------------------------------------------- 1 | """tarball 2 | 3 | Tool-specific initialization for tarball. 4 | 5 | """ 6 | 7 | ## Commands to tackle a command based implementation: 8 | ##to unpack on the fly... 9 | ##gunzip < FILE.tar.gz | tar xvf - 10 | ##to pack on the fly... 11 | ##tar cvf - FILE-LIST | gzip -c > FILE.tar.gz 12 | 13 | import os.path 14 | 15 | import SCons.Builder 16 | import SCons.Node.FS 17 | import SCons.Util 18 | 19 | try: 20 | import gzip 21 | import tarfile 22 | internal_targz = 1 23 | except ImportError: 24 | internal_targz = 0 25 | 26 | TARGZ_DEFAULT_COMPRESSION_LEVEL = 9 27 | 28 | if internal_targz: 29 | def targz(target, source, env): 30 | def archive_name( path ): 31 | path = os.path.normpath( os.path.abspath( path ) ) 32 | common_path = os.path.commonprefix( (base_dir, path) ) 33 | archive_name = path[len(common_path):] 34 | return archive_name 35 | 36 | def visit(tar, dirname, names): 37 | for name in names: 38 | path = os.path.join(dirname, name) 39 | if os.path.isfile(path): 40 | tar.add(path, archive_name(path) ) 41 | compression = env.get('TARGZ_COMPRESSION_LEVEL',TARGZ_DEFAULT_COMPRESSION_LEVEL) 42 | base_dir = os.path.normpath( env.get('TARGZ_BASEDIR', env.Dir('.')).abspath ) 43 | target_path = str(target[0]) 44 | fileobj = gzip.GzipFile( target_path, 'wb', compression ) 45 | tar = tarfile.TarFile(os.path.splitext(target_path)[0], 'w', fileobj) 46 | for source in source: 47 | source_path = str(source) 48 | if source.isdir(): 49 | os.path.walk(source_path, visit, tar) 50 | else: 51 | tar.add(source_path, archive_name(source_path) ) # filename, arcname 52 | tar.close() 53 | 54 | targzAction = SCons.Action.Action(targz, varlist=['TARGZ_COMPRESSION_LEVEL','TARGZ_BASEDIR']) 55 | 56 | def makeBuilder( emitter = None ): 57 | return SCons.Builder.Builder(action = SCons.Action.Action('$TARGZ_COM', '$TARGZ_COMSTR'), 58 | source_factory = SCons.Node.FS.Entry, 59 | source_scanner = SCons.Defaults.DirScanner, 60 | suffix = '$TARGZ_SUFFIX', 61 | multi = 1) 62 | TarGzBuilder = makeBuilder() 63 | 64 | def generate(env): 65 | """Add Builders and construction variables for zip to an Environment. 66 | The following environnement variables may be set: 67 | TARGZ_COMPRESSION_LEVEL: integer, [0-9]. 0: no compression, 9: best compression (same as gzip compression level). 68 | TARGZ_BASEDIR: base-directory used to determine archive name (this allow archive name to be relative 69 | to something other than top-dir). 70 | """ 71 | env['BUILDERS']['TarGz'] = TarGzBuilder 72 | env['TARGZ_COM'] = targzAction 73 | env['TARGZ_COMPRESSION_LEVEL'] = TARGZ_DEFAULT_COMPRESSION_LEVEL # range 0-9 74 | env['TARGZ_SUFFIX'] = '.tar.gz' 75 | env['TARGZ_BASEDIR'] = env.Dir('.') # Sources archive name are made relative to that directory. 76 | else: 77 | def generate(env): 78 | pass 79 | 80 | 81 | def exists(env): 82 | return internal_targz 83 | -------------------------------------------------------------------------------- /scons-tools/targz.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/scons-tools/targz.pyc -------------------------------------------------------------------------------- /src/benchmark/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | int64_t getCurrentTime() 12 | { 13 | struct timeval tval; 14 | gettimeofday(&tval, NULL); 15 | return (tval.tv_sec * 1000000LL + tval.tv_usec); 16 | } 17 | 18 | char * key = "abcdef"; 19 | char * str = "abcdefghijklmnopqrstuvwxyz'fuck CPC"; 20 | 21 | void test() 22 | { 23 | int doc_count = 40; 24 | int outer_field_count = 80; 25 | 26 | std::vector vec; 27 | 28 | for( size_t j=0 ; j 2 | #include // sort 3 | #include 4 | 5 | #if defined(_MSC_VER) && _MSC_VER >= 1310 6 | # pragma warning( disable: 4996 ) // disable fopen deprecation warning 7 | #endif 8 | 9 | static std::string 10 | readInputTestFile( const char *path ) 11 | { 12 | FILE *file = fopen( path, "rb" ); 13 | if ( !file ) 14 | return std::string(""); 15 | fseek( file, 0, SEEK_END ); 16 | long size = ftell( file ); 17 | fseek( file, 0, SEEK_SET ); 18 | std::string text; 19 | char *buffer = new char[size+1]; 20 | buffer[size] = 0; 21 | if ( fread( buffer, 1, size, file ) == (unsigned long)size ) 22 | text = buffer; 23 | fclose( file ); 24 | delete[] buffer; 25 | return text; 26 | } 27 | 28 | 29 | static void 30 | printValueTree( FILE *fout, Json::Value &value, const std::string &path = "." ) 31 | { 32 | switch ( value.type() ) 33 | { 34 | case Json::nullValue: 35 | fprintf( fout, "%s=null\n", path.c_str() ); 36 | break; 37 | case Json::intValue: 38 | fprintf( fout, "%s=%d\n", path.c_str(), value.asInt() ); 39 | break; 40 | case Json::uintValue: 41 | fprintf( fout, "%s=%u\n", path.c_str(), value.asUInt() ); 42 | break; 43 | case Json::realValue: 44 | fprintf( fout, "%s=%.16g\n", path.c_str(), value.asDouble() ); 45 | break; 46 | case Json::stringValue: 47 | fprintf( fout, "%s=\"%s\"\n", path.c_str(), value.asString().c_str() ); 48 | break; 49 | case Json::booleanValue: 50 | fprintf( fout, "%s=%s\n", path.c_str(), value.asBool() ? "true" : "false" ); 51 | break; 52 | case Json::arrayValue: 53 | { 54 | fprintf( fout, "%s=[]\n", path.c_str() ); 55 | int size = value.size(); 56 | for ( int index =0; index < size; ++index ) 57 | { 58 | static char buffer[16]; 59 | sprintf( buffer, "[%d]", index ); 60 | printValueTree( fout, value[index], path + buffer ); 61 | } 62 | } 63 | break; 64 | case Json::objectValue: 65 | { 66 | fprintf( fout, "%s={}\n", path.c_str() ); 67 | Json::Value::Members members( value.getMemberNames() ); 68 | std::sort( members.begin(), members.end() ); 69 | std::string suffix = *(path.end()-1) == '.' ? "" : "."; 70 | for ( Json::Value::Members::iterator it = members.begin(); 71 | it != members.end(); 72 | ++it ) 73 | { 74 | const std::string &name = *it; 75 | printValueTree( fout, value[name], path + suffix + name ); 76 | } 77 | } 78 | break; 79 | default: 80 | break; 81 | } 82 | } 83 | 84 | 85 | static int 86 | parseAndSaveValueTree( const std::string &input, 87 | const std::string &actual, 88 | const std::string &kind, 89 | Json::Value &root, 90 | const Json::Features &features, 91 | bool parseOnly ) 92 | { 93 | Json::Reader reader( features ); 94 | bool parsingSuccessful = reader.parse( input, root ); 95 | if ( !parsingSuccessful ) 96 | { 97 | printf( "Failed to parse %s file: \n%s\n", 98 | kind.c_str(), 99 | reader.getFormatedErrorMessages().c_str() ); 100 | return 1; 101 | } 102 | 103 | if ( !parseOnly ) 104 | { 105 | FILE *factual = fopen( actual.c_str(), "wt" ); 106 | if ( !factual ) 107 | { 108 | printf( "Failed to create %s actual file.\n", kind.c_str() ); 109 | return 2; 110 | } 111 | printValueTree( factual, root ); 112 | fclose( factual ); 113 | } 114 | return 0; 115 | } 116 | 117 | 118 | static int 119 | rewriteValueTree( const std::string &rewritePath, 120 | const Json::Value &root, 121 | std::string &rewrite ) 122 | { 123 | //Json::FastWriter writer; 124 | //writer.enableYAMLCompatibility(); 125 | Json::StyledWriter writer; 126 | rewrite = writer.write( root ); 127 | FILE *fout = fopen( rewritePath.c_str(), "wt" ); 128 | if ( !fout ) 129 | { 130 | printf( "Failed to create rewrite file: %s\n", rewritePath.c_str() ); 131 | return 2; 132 | } 133 | fprintf( fout, "%s\n", rewrite.c_str() ); 134 | fclose( fout ); 135 | return 0; 136 | } 137 | 138 | 139 | static std::string 140 | removeSuffix( const std::string &path, 141 | const std::string &extension ) 142 | { 143 | if ( extension.length() >= path.length() ) 144 | return std::string(""); 145 | std::string suffix = path.substr( path.length() - extension.length() ); 146 | if ( suffix != extension ) 147 | return std::string(""); 148 | return path.substr( 0, path.length() - extension.length() ); 149 | } 150 | 151 | static int 152 | printUsage( const char *argv[] ) 153 | { 154 | printf( "Usage: %s [--strict] input-json-file", argv[0] ); 155 | return 3; 156 | } 157 | 158 | 159 | int 160 | parseCommandLine( int argc, const char *argv[], 161 | Json::Features &features, std::string &path, 162 | bool &parseOnly ) 163 | { 164 | parseOnly = false; 165 | if ( argc < 2 ) 166 | { 167 | return printUsage( argv ); 168 | } 169 | 170 | int index = 1; 171 | if ( std::string(argv[1]) == "--json-checker" ) 172 | { 173 | features = Json::Features::strictMode(); 174 | parseOnly = true; 175 | ++index; 176 | } 177 | 178 | if ( index == argc || index + 1 < argc ) 179 | { 180 | return printUsage( argv ); 181 | } 182 | 183 | path = argv[index]; 184 | return 0; 185 | } 186 | 187 | 188 | int main( int argc, const char *argv[] ) 189 | { 190 | std::string path; 191 | Json::Features features; 192 | bool parseOnly; 193 | int exitCode = parseCommandLine( argc, argv, features, path, parseOnly ); 194 | if ( exitCode != 0 ) 195 | { 196 | return exitCode; 197 | } 198 | 199 | std::string input = readInputTestFile( path.c_str() ); 200 | if ( input.empty() ) 201 | { 202 | printf( "Failed to read input or empty input: %s\n", path.c_str() ); 203 | return 3; 204 | } 205 | 206 | std::string basePath = removeSuffix( argv[1], ".json" ); 207 | if ( !parseOnly && basePath.empty() ) 208 | { 209 | printf( "Bad input path. Path does not end with '.expected':\n%s\n", path.c_str() ); 210 | return 3; 211 | } 212 | 213 | std::string actualPath = basePath + ".actual"; 214 | std::string rewritePath = basePath + ".rewrite"; 215 | std::string rewriteActualPath = basePath + ".actual-rewrite"; 216 | 217 | Json::Value root; 218 | exitCode = parseAndSaveValueTree( input, actualPath, "input", root, features, parseOnly ); 219 | if ( exitCode == 0 && !parseOnly ) 220 | { 221 | std::string rewrite; 222 | exitCode = rewriteValueTree( rewritePath, root, rewrite ); 223 | if ( exitCode == 0 ) 224 | { 225 | Json::Value rewriteRoot; 226 | exitCode = parseAndSaveValueTree( rewrite, rewriteActualPath, 227 | "rewrite", rewriteRoot, features, parseOnly ); 228 | } 229 | } 230 | 231 | return exitCode; 232 | } 233 | 234 | -------------------------------------------------------------------------------- /src/jsontestrunner/sconscript: -------------------------------------------------------------------------------- 1 | Import( 'env_testing buildJSONTests' ) 2 | 3 | buildJSONTests( env_testing, Split( """ 4 | main.cpp 5 | """ ), 6 | 'jsontestrunner' ) 7 | 8 | # For 'check' to work, 'libs' must be built first. 9 | env_testing.Depends('jsontestrunner', '#libs') 10 | -------------------------------------------------------------------------------- /src/lib_json/json_batchallocator.h: -------------------------------------------------------------------------------- 1 | #ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED 2 | # define JSONCPP_BATCHALLOCATOR_H_INCLUDED 3 | 4 | # include 5 | # include 6 | 7 | # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION 8 | 9 | namespace Json { 10 | 11 | /* Fast memory allocator. 12 | * 13 | * This memory allocator allocates memory for a batch of object (specified by 14 | * the page size, the number of object in each page). 15 | * 16 | * It does not allow the destruction of a single object. All the allocated objects 17 | * can be destroyed at once. The memory can be either released or reused for future 18 | * allocation. 19 | * 20 | * The in-place new operator must be used to construct the object using the pointer 21 | * returned by allocate. 22 | */ 23 | template 25 | class BatchAllocator 26 | { 27 | public: 28 | typedef AllocatedType Type; 29 | 30 | BatchAllocator( unsigned int objectsPerPage = 255 ) 31 | : freeHead_( 0 ) 32 | , objectsPerPage_( objectsPerPage ) 33 | { 34 | // printf( "Size: %d => %s\n", sizeof(AllocatedType), typeid(AllocatedType).name() ); 35 | assert( sizeof(AllocatedType) * objectPerAllocation >= sizeof(AllocatedType *) ); // We must be able to store a slist in the object free space. 36 | assert( objectsPerPage >= 16 ); 37 | batches_ = allocateBatch( 0 ); // allocated a dummy page 38 | currentBatch_ = batches_; 39 | } 40 | 41 | ~BatchAllocator() 42 | { 43 | for ( BatchInfo *batch = batches_; batch; ) 44 | { 45 | BatchInfo *nextBatch = batch->next_; 46 | free( batch ); 47 | batch = nextBatch; 48 | } 49 | } 50 | 51 | /// allocate space for an array of objectPerAllocation object. 52 | /// @warning it is the responsability of the caller to call objects constructors. 53 | AllocatedType *allocate() 54 | { 55 | if ( freeHead_ ) // returns node from free list. 56 | { 57 | AllocatedType *object = freeHead_; 58 | freeHead_ = *(AllocatedType **)object; 59 | return object; 60 | } 61 | if ( currentBatch_->used_ == currentBatch_->end_ ) 62 | { 63 | currentBatch_ = currentBatch_->next_; 64 | while ( currentBatch_ && currentBatch_->used_ == currentBatch_->end_ ) 65 | currentBatch_ = currentBatch_->next_; 66 | 67 | if ( !currentBatch_ ) // no free batch found, allocate a new one 68 | { 69 | currentBatch_ = allocateBatch( objectsPerPage_ ); 70 | currentBatch_->next_ = batches_; // insert at the head of the list 71 | batches_ = currentBatch_; 72 | } 73 | } 74 | AllocatedType *allocated = currentBatch_->used_; 75 | currentBatch_->used_ += objectPerAllocation; 76 | return allocated; 77 | } 78 | 79 | /// Release the object. 80 | /// @warning it is the responsability of the caller to actually destruct the object. 81 | void release( AllocatedType *object ) 82 | { 83 | assert( object != 0 ); 84 | *(AllocatedType **)object = freeHead_; 85 | freeHead_ = object; 86 | } 87 | 88 | private: 89 | struct BatchInfo 90 | { 91 | BatchInfo *next_; 92 | AllocatedType *used_; 93 | AllocatedType *end_; 94 | AllocatedType buffer_[objectPerAllocation]; 95 | }; 96 | 97 | // disabled copy constructor and assignement operator. 98 | BatchAllocator( const BatchAllocator & ); 99 | void operator =( const BatchAllocator &); 100 | 101 | static BatchInfo *allocateBatch( unsigned int objectsPerPage ) 102 | { 103 | const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType)* objectPerAllocation 104 | + sizeof(AllocatedType) * objectPerAllocation * objectsPerPage; 105 | BatchInfo *batch = static_cast( malloc( mallocSize ) ); 106 | batch->next_ = 0; 107 | batch->used_ = batch->buffer_; 108 | batch->end_ = batch->buffer_ + objectsPerPage; 109 | return batch; 110 | } 111 | 112 | BatchInfo *batches_; 113 | BatchInfo *currentBatch_; 114 | /// Head of a single linked list within the allocated space of freeed object 115 | AllocatedType *freeHead_; 116 | unsigned int objectsPerPage_; 117 | }; 118 | 119 | 120 | } // namespace Json 121 | 122 | # endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION 123 | 124 | #endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED 125 | 126 | -------------------------------------------------------------------------------- /src/lib_json/json_valueiterator.inl: -------------------------------------------------------------------------------- 1 | // included by json_value.cpp 2 | // everything is within Json namespace 3 | 4 | 5 | // ////////////////////////////////////////////////////////////////// 6 | // ////////////////////////////////////////////////////////////////// 7 | // ////////////////////////////////////////////////////////////////// 8 | // class ValueIteratorBase 9 | // ////////////////////////////////////////////////////////////////// 10 | // ////////////////////////////////////////////////////////////////// 11 | // ////////////////////////////////////////////////////////////////// 12 | 13 | ValueIteratorBase::ValueIteratorBase() 14 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 15 | : current_() 16 | , isNull_( true ) 17 | { 18 | } 19 | #else 20 | : isArray_( true ) 21 | , isNull_( true ) 22 | { 23 | iterator_.array_ = ValueInternalArray::IteratorState(); 24 | } 25 | #endif 26 | 27 | 28 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 29 | ValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator ¤t ) 30 | : current_( current ) 31 | , isNull_( false ) 32 | { 33 | } 34 | #else 35 | ValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state ) 36 | : isArray_( true ) 37 | { 38 | iterator_.array_ = state; 39 | } 40 | 41 | 42 | ValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state ) 43 | : isArray_( false ) 44 | { 45 | iterator_.map_ = state; 46 | } 47 | #endif 48 | 49 | Value & 50 | ValueIteratorBase::deref() const 51 | { 52 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 53 | return current_->second; 54 | #else 55 | if ( isArray_ ) 56 | return ValueInternalArray::dereference( iterator_.array_ ); 57 | return ValueInternalMap::value( iterator_.map_ ); 58 | #endif 59 | } 60 | 61 | 62 | void 63 | ValueIteratorBase::increment() 64 | { 65 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 66 | ++current_; 67 | #else 68 | if ( isArray_ ) 69 | ValueInternalArray::increment( iterator_.array_ ); 70 | ValueInternalMap::increment( iterator_.map_ ); 71 | #endif 72 | } 73 | 74 | 75 | void 76 | ValueIteratorBase::decrement() 77 | { 78 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 79 | --current_; 80 | #else 81 | if ( isArray_ ) 82 | ValueInternalArray::decrement( iterator_.array_ ); 83 | ValueInternalMap::decrement( iterator_.map_ ); 84 | #endif 85 | } 86 | 87 | 88 | ValueIteratorBase::difference_type 89 | ValueIteratorBase::computeDistance( const SelfType &other ) const 90 | { 91 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 92 | # ifdef JSON_USE_CPPTL_SMALLMAP 93 | return current_ - other.current_; 94 | # else 95 | // Iterator for null value are initialized using the default 96 | // constructor, which initialize current_ to the default 97 | // std::map::iterator. As begin() and end() are two instance 98 | // of the default std::map::iterator, they can not be compared. 99 | // To allow this, we handle this comparison specifically. 100 | if ( isNull_ && other.isNull_ ) 101 | { 102 | return 0; 103 | } 104 | 105 | 106 | // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL, 107 | // which is the one used by default). 108 | // Using a portable hand-made version for non random iterator instead: 109 | // return difference_type( std::distance( current_, other.current_ ) ); 110 | difference_type myDistance = 0; 111 | for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it ) 112 | { 113 | ++myDistance; 114 | } 115 | return myDistance; 116 | # endif 117 | #else 118 | if ( isArray_ ) 119 | return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ ); 120 | return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ ); 121 | #endif 122 | } 123 | 124 | 125 | bool 126 | ValueIteratorBase::isEqual( const SelfType &other ) const 127 | { 128 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 129 | if ( isNull_ ) 130 | { 131 | return other.isNull_; 132 | } 133 | return current_ == other.current_; 134 | #else 135 | if ( isArray_ ) 136 | return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ ); 137 | return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ ); 138 | #endif 139 | } 140 | 141 | 142 | void 143 | ValueIteratorBase::copy( const SelfType &other ) 144 | { 145 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 146 | current_ = other.current_; 147 | #else 148 | if ( isArray_ ) 149 | iterator_.array_ = other.iterator_.array_; 150 | iterator_.map_ = other.iterator_.map_; 151 | #endif 152 | } 153 | 154 | 155 | Value 156 | ValueIteratorBase::key() const 157 | { 158 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 159 | const Value::CZString czstring = (*current_).first; 160 | if ( czstring.c_str() ) 161 | { 162 | if ( czstring.isStaticString() ) 163 | return Value( StaticString( czstring.c_str() ) ); 164 | return Value( czstring.c_str() ); 165 | } 166 | return Value( czstring.index() ); 167 | #else 168 | if ( isArray_ ) 169 | return Value( ValueInternalArray::indexOf( iterator_.array_ ) ); 170 | bool isStatic; 171 | const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic ); 172 | if ( isStatic ) 173 | return Value( StaticString( memberName ) ); 174 | return Value( memberName ); 175 | #endif 176 | } 177 | 178 | 179 | UInt 180 | ValueIteratorBase::index() const 181 | { 182 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 183 | const Value::CZString czstring = (*current_).first; 184 | if ( !czstring.c_str() ) 185 | return czstring.index(); 186 | return Value::UInt( -1 ); 187 | #else 188 | if ( isArray_ ) 189 | return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) ); 190 | return Value::UInt( -1 ); 191 | #endif 192 | } 193 | 194 | 195 | const char * 196 | ValueIteratorBase::memberName() const 197 | { 198 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 199 | const char *name = (*current_).first.c_str(); 200 | return name ? name : ""; 201 | #else 202 | if ( !isArray_ ) 203 | return ValueInternalMap::key( iterator_.map_ ); 204 | return ""; 205 | #endif 206 | } 207 | 208 | 209 | // ////////////////////////////////////////////////////////////////// 210 | // ////////////////////////////////////////////////////////////////// 211 | // ////////////////////////////////////////////////////////////////// 212 | // class ValueConstIterator 213 | // ////////////////////////////////////////////////////////////////// 214 | // ////////////////////////////////////////////////////////////////// 215 | // ////////////////////////////////////////////////////////////////// 216 | 217 | ValueConstIterator::ValueConstIterator() 218 | { 219 | } 220 | 221 | 222 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 223 | ValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator ¤t ) 224 | : ValueIteratorBase( current ) 225 | { 226 | } 227 | #else 228 | ValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state ) 229 | : ValueIteratorBase( state ) 230 | { 231 | } 232 | 233 | ValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state ) 234 | : ValueIteratorBase( state ) 235 | { 236 | } 237 | #endif 238 | 239 | ValueConstIterator & 240 | ValueConstIterator::operator =( const ValueIteratorBase &other ) 241 | { 242 | copy( other ); 243 | return *this; 244 | } 245 | 246 | 247 | // ////////////////////////////////////////////////////////////////// 248 | // ////////////////////////////////////////////////////////////////// 249 | // ////////////////////////////////////////////////////////////////// 250 | // class ValueIterator 251 | // ////////////////////////////////////////////////////////////////// 252 | // ////////////////////////////////////////////////////////////////// 253 | // ////////////////////////////////////////////////////////////////// 254 | 255 | ValueIterator::ValueIterator() 256 | { 257 | } 258 | 259 | 260 | #ifndef JSON_VALUE_USE_INTERNAL_MAP 261 | ValueIterator::ValueIterator( const Value::ObjectValues::iterator ¤t ) 262 | : ValueIteratorBase( current ) 263 | { 264 | } 265 | #else 266 | ValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state ) 267 | : ValueIteratorBase( state ) 268 | { 269 | } 270 | 271 | ValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state ) 272 | : ValueIteratorBase( state ) 273 | { 274 | } 275 | #endif 276 | 277 | ValueIterator::ValueIterator( const ValueConstIterator &other ) 278 | : ValueIteratorBase( other ) 279 | { 280 | } 281 | 282 | ValueIterator::ValueIterator( const ValueIterator &other ) 283 | : ValueIteratorBase( other ) 284 | { 285 | } 286 | 287 | ValueIterator & 288 | ValueIterator::operator =( const SelfType &other ) 289 | { 290 | copy( other ); 291 | return *this; 292 | } 293 | -------------------------------------------------------------------------------- /src/lib_json/sconscript: -------------------------------------------------------------------------------- 1 | Import( 'env buildLibrary' ) 2 | 3 | buildLibrary( env, Split( """ 4 | json_reader.cpp 5 | json_value.cpp 6 | json_writer.cpp 7 | """ ), 8 | 'json' ) 9 | -------------------------------------------------------------------------------- /src/test_lib_json/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "jsontest.h" 3 | 4 | 5 | // TODO: 6 | // - boolean value returns that they are integral. Should not be. 7 | // - unsigned integer in integer range are not considered to be valid integer. Should check range. 8 | 9 | 10 | // ////////////////////////////////////////////////////////////////// 11 | // ////////////////////////////////////////////////////////////////// 12 | // Json Library test cases 13 | // ////////////////////////////////////////////////////////////////// 14 | // ////////////////////////////////////////////////////////////////// 15 | 16 | 17 | struct ValueTest : JsonTest::TestCase 18 | { 19 | Json::Value null_; 20 | Json::Value emptyArray_; 21 | Json::Value emptyObject_; 22 | Json::Value integer_; 23 | Json::Value unsignedInteger_; 24 | Json::Value smallUnsignedInteger_; 25 | Json::Value real_; 26 | Json::Value array1_; 27 | Json::Value object1_; 28 | Json::Value emptyString_; 29 | Json::Value string1_; 30 | Json::Value string_; 31 | Json::Value true_; 32 | Json::Value false_; 33 | 34 | ValueTest() 35 | : emptyArray_( Json::arrayValue ) 36 | , emptyObject_( Json::objectValue ) 37 | , integer_( 123456789 ) 38 | , smallUnsignedInteger_( Json::Value::UInt( Json::Value::maxInt ) ) 39 | , unsignedInteger_( 34567890u ) 40 | , real_( 1234.56789 ) 41 | , emptyString_( "" ) 42 | , string1_( "a" ) 43 | , string_( "sometext with space" ) 44 | , true_( true ) 45 | , false_( false ) 46 | { 47 | array1_.append( 1234 ); 48 | object1_["id"] = 1234; 49 | } 50 | 51 | struct IsCheck 52 | { 53 | /// Initialize all checks to \c false by default. 54 | IsCheck(); 55 | 56 | bool isObject_; 57 | bool isArray_; 58 | bool isBool_; 59 | bool isDouble_; 60 | bool isInt_; 61 | bool isUInt_; 62 | bool isIntegral_; 63 | bool isNumeric_; 64 | bool isString_; 65 | bool isNull_; 66 | }; 67 | 68 | void checkConstMemberCount( const Json::Value &value, unsigned int expectedCount ); 69 | 70 | void checkMemberCount( Json::Value &value, unsigned int expectedCount ); 71 | 72 | void checkIs( const Json::Value &value, const IsCheck &check ); 73 | }; 74 | 75 | 76 | JSONTEST_FIXTURE( ValueTest, size ) 77 | { 78 | JSONTEST_ASSERT_PRED( checkMemberCount(emptyArray_, 0) ); 79 | JSONTEST_ASSERT_PRED( checkMemberCount(emptyObject_, 0) ); 80 | JSONTEST_ASSERT_PRED( checkMemberCount(array1_, 1) ); 81 | JSONTEST_ASSERT_PRED( checkMemberCount(object1_, 1) ); 82 | JSONTEST_ASSERT_PRED( checkMemberCount(null_, 0) ); 83 | JSONTEST_ASSERT_PRED( checkMemberCount(integer_, 0) ); 84 | JSONTEST_ASSERT_PRED( checkMemberCount(real_, 0) ); 85 | JSONTEST_ASSERT_PRED( checkMemberCount(emptyString_, 0) ); 86 | JSONTEST_ASSERT_PRED( checkMemberCount(string_, 0) ); 87 | JSONTEST_ASSERT_PRED( checkMemberCount(true_, 0) ); 88 | } 89 | 90 | 91 | JSONTEST_FIXTURE( ValueTest, isObject ) 92 | { 93 | IsCheck checks; 94 | checks.isObject_ = true; 95 | JSONTEST_ASSERT_PRED( checkIs( emptyObject_, checks ) ); 96 | JSONTEST_ASSERT_PRED( checkIs( object1_, checks ) ); 97 | } 98 | 99 | 100 | JSONTEST_FIXTURE( ValueTest, isArray ) 101 | { 102 | IsCheck checks; 103 | checks.isArray_ = true; 104 | JSONTEST_ASSERT_PRED( checkIs( emptyArray_, checks ) ); 105 | JSONTEST_ASSERT_PRED( checkIs( array1_, checks ) ); 106 | } 107 | 108 | 109 | JSONTEST_FIXTURE( ValueTest, isNull ) 110 | { 111 | IsCheck checks; 112 | checks.isNull_ = true; 113 | checks.isObject_ = true; 114 | checks.isArray_ = true; 115 | JSONTEST_ASSERT_PRED( checkIs( null_, checks ) ); 116 | } 117 | 118 | 119 | JSONTEST_FIXTURE( ValueTest, isString ) 120 | { 121 | IsCheck checks; 122 | checks.isString_ = true; 123 | JSONTEST_ASSERT_PRED( checkIs( emptyString_, checks ) ); 124 | JSONTEST_ASSERT_PRED( checkIs( string_, checks ) ); 125 | JSONTEST_ASSERT_PRED( checkIs( string1_, checks ) ); 126 | } 127 | 128 | 129 | JSONTEST_FIXTURE( ValueTest, isBool ) 130 | { 131 | IsCheck checks; 132 | checks.isBool_ = true; 133 | checks.isIntegral_ = true; 134 | checks.isNumeric_ = true; 135 | JSONTEST_ASSERT_PRED( checkIs( false_, checks ) ); 136 | JSONTEST_ASSERT_PRED( checkIs( true_, checks ) ); 137 | } 138 | 139 | 140 | JSONTEST_FIXTURE( ValueTest, isDouble ) 141 | { 142 | IsCheck checks; 143 | checks.isDouble_ = true; 144 | checks.isNumeric_ = true; 145 | JSONTEST_ASSERT_PRED( checkIs( real_, checks ) ); 146 | } 147 | 148 | 149 | JSONTEST_FIXTURE( ValueTest, isInt ) 150 | { 151 | IsCheck checks; 152 | checks.isInt_ = true; 153 | checks.isNumeric_ = true; 154 | checks.isIntegral_ = true; 155 | JSONTEST_ASSERT_PRED( checkIs( integer_, checks ) ); 156 | } 157 | 158 | 159 | JSONTEST_FIXTURE( ValueTest, isUInt ) 160 | { 161 | IsCheck checks; 162 | checks.isUInt_ = true; 163 | checks.isNumeric_ = true; 164 | checks.isIntegral_ = true; 165 | JSONTEST_ASSERT_PRED( checkIs( unsignedInteger_, checks ) ); 166 | JSONTEST_ASSERT_PRED( checkIs( smallUnsignedInteger_, checks ) ); 167 | } 168 | 169 | 170 | void 171 | ValueTest::checkConstMemberCount( const Json::Value &value, unsigned int expectedCount ) 172 | { 173 | unsigned int count = 0; 174 | Json::Value::const_iterator itEnd = value.end(); 175 | for ( Json::Value::const_iterator it = value.begin(); it != itEnd; ++it ) 176 | { 177 | ++count; 178 | } 179 | JSONTEST_ASSERT_EQUAL( expectedCount, count ) << "Json::Value::const_iterator"; 180 | } 181 | 182 | void 183 | ValueTest::checkMemberCount( Json::Value &value, unsigned int expectedCount ) 184 | { 185 | JSONTEST_ASSERT_EQUAL( expectedCount, value.size() ); 186 | 187 | unsigned int count = 0; 188 | Json::Value::iterator itEnd = value.end(); 189 | for ( Json::Value::iterator it = value.begin(); it != itEnd; ++it ) 190 | { 191 | ++count; 192 | } 193 | JSONTEST_ASSERT_EQUAL( expectedCount, count ) << "Json::Value::iterator"; 194 | 195 | JSONTEST_ASSERT_PRED( checkConstMemberCount(value, expectedCount) ); 196 | } 197 | 198 | 199 | ValueTest::IsCheck::IsCheck() 200 | : isObject_( false ) 201 | , isArray_( false ) 202 | , isBool_( false ) 203 | , isDouble_( false ) 204 | , isInt_( false ) 205 | , isUInt_( false ) 206 | , isIntegral_( false ) 207 | , isNumeric_( false ) 208 | , isString_( false ) 209 | , isNull_( false ) 210 | { 211 | } 212 | 213 | 214 | void 215 | ValueTest::checkIs( const Json::Value &value, const IsCheck &check ) 216 | { 217 | JSONTEST_ASSERT_EQUAL( check.isObject_, value.isObject() ); 218 | JSONTEST_ASSERT_EQUAL( check.isArray_, value.isArray() ); 219 | JSONTEST_ASSERT_EQUAL( check.isBool_, value.isBool() ); 220 | JSONTEST_ASSERT_EQUAL( check.isDouble_, value.isDouble() ); 221 | JSONTEST_ASSERT_EQUAL( check.isInt_, value.isInt() ); 222 | JSONTEST_ASSERT_EQUAL( check.isUInt_, value.isUInt() ); 223 | JSONTEST_ASSERT_EQUAL( check.isIntegral_, value.isIntegral() ); 224 | JSONTEST_ASSERT_EQUAL( check.isNumeric_, value.isNumeric() ); 225 | JSONTEST_ASSERT_EQUAL( check.isString_, value.isString() ); 226 | JSONTEST_ASSERT_EQUAL( check.isNull_, value.isNull() ); 227 | } 228 | 229 | 230 | 231 | int main( int argc, const char *argv[] ) 232 | { 233 | JsonTest::Runner runner; 234 | JSONTEST_REGISTER_FIXTURE( runner, ValueTest, size ); 235 | JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isObject ); 236 | JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isArray ); 237 | JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isBool ); 238 | JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isInt ); 239 | JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isUInt ); 240 | JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isDouble ); 241 | JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isString ); 242 | JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isNull ); 243 | return runner.runCommandLine( argc, argv ); 244 | } 245 | -------------------------------------------------------------------------------- /src/test_lib_json/sconscript: -------------------------------------------------------------------------------- 1 | Import( 'env_testing buildUnitTests' ) 2 | 3 | buildUnitTests( env_testing, Split( """ 4 | main.cpp 5 | jsontest.cpp 6 | """ ), 7 | 'test_lib_json' ) 8 | 9 | # For 'check' to work, 'libs' must be built first. 10 | env_testing.Depends('test_lib_json', '#libs') 11 | -------------------------------------------------------------------------------- /test/cleantests.py: -------------------------------------------------------------------------------- 1 | # removes all files created during testing 2 | import glob 3 | import os 4 | 5 | paths = [] 6 | for pattern in [ '*.actual', '*.actual-rewrite', '*.rewrite', '*.process-output' ]: 7 | paths += glob.glob( 'data/' + pattern ) 8 | 9 | for path in paths: 10 | os.unlink( path ) 11 | -------------------------------------------------------------------------------- /test/data/test_array_01.actual: -------------------------------------------------------------------------------- 1 | .=[] 2 | -------------------------------------------------------------------------------- /test/data/test_array_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=[] 2 | -------------------------------------------------------------------------------- /test/data/test_array_01.expected: -------------------------------------------------------------------------------- 1 | .=[] 2 | -------------------------------------------------------------------------------- /test/data/test_array_01.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /test/data/test_array_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_array_01.process-output -------------------------------------------------------------------------------- /test/data/test_array_01.rewrite: -------------------------------------------------------------------------------- 1 | [] 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_array_02.actual: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | -------------------------------------------------------------------------------- /test/data/test_array_02.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | -------------------------------------------------------------------------------- /test/data/test_array_02.expected: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | -------------------------------------------------------------------------------- /test/data/test_array_02.json: -------------------------------------------------------------------------------- 1 | [1] 2 | -------------------------------------------------------------------------------- /test/data/test_array_02.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_array_02.process-output -------------------------------------------------------------------------------- /test/data/test_array_02.rewrite: -------------------------------------------------------------------------------- 1 | [ 1 ] 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_array_03.actual: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | .[1]=2 4 | .[2]=3 5 | .[3]=4 6 | .[4]=5 7 | -------------------------------------------------------------------------------- /test/data/test_array_03.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | .[1]=2 4 | .[2]=3 5 | .[3]=4 6 | .[4]=5 7 | -------------------------------------------------------------------------------- /test/data/test_array_03.expected: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | .[1]=2 4 | .[2]=3 5 | .[3]=4 6 | .[4]=5 7 | -------------------------------------------------------------------------------- /test/data/test_array_03.json: -------------------------------------------------------------------------------- 1 | [ 1, 2 , 3,4,5] 2 | -------------------------------------------------------------------------------- /test/data/test_array_03.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_array_03.process-output -------------------------------------------------------------------------------- /test/data/test_array_03.rewrite: -------------------------------------------------------------------------------- 1 | [ 1, 2, 3, 4, 5 ] 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_array_04.actual: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | .[1]="abc" 4 | .[2]=12.3 5 | .[3]=-4 6 | -------------------------------------------------------------------------------- /test/data/test_array_04.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | .[1]="abc" 4 | .[2]=12.3 5 | .[3]=-4 6 | -------------------------------------------------------------------------------- /test/data/test_array_04.expected: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | .[1]="abc" 4 | .[2]=12.3 5 | .[3]=-4 6 | -------------------------------------------------------------------------------- /test/data/test_array_04.json: -------------------------------------------------------------------------------- 1 | [1, "abc" , 12.3, -4] 2 | -------------------------------------------------------------------------------- /test/data/test_array_04.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_array_04.process-output -------------------------------------------------------------------------------- /test/data/test_array_04.rewrite: -------------------------------------------------------------------------------- 1 | [ 1, "abc", 12.30, -4 ] 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_array_05.actual: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | .[1]=2 4 | .[2]=3 5 | .[3]=4 6 | .[4]=5 7 | .[5]=6 8 | .[6]=7 9 | .[7]=8 10 | .[8]=9 11 | .[9]=10 12 | .[10]=11 13 | .[11]=12 14 | .[12]=13 15 | .[13]=14 16 | .[14]=15 17 | .[15]=16 18 | .[16]=17 19 | .[17]=18 20 | .[18]=19 21 | .[19]=20 22 | .[20]=21 23 | .[21]=22 24 | .[22]=23 25 | .[23]=24 26 | .[24]=25 27 | .[25]=26 28 | .[26]=27 29 | .[27]=28 30 | .[28]=29 31 | .[29]=30 32 | .[30]=31 33 | .[31]=32 34 | .[32]=33 35 | .[33]=34 36 | .[34]=35 37 | .[35]=36 38 | .[36]=37 39 | .[37]=38 40 | .[38]=39 41 | .[39]=40 42 | .[40]=41 43 | .[41]=42 44 | .[42]=43 45 | .[43]=44 46 | .[44]=45 47 | .[45]=46 48 | .[46]=47 49 | .[47]=48 50 | .[48]=49 51 | .[49]=50 52 | .[50]=51 53 | .[51]=52 54 | .[52]=53 55 | .[53]=54 56 | .[54]=55 57 | .[55]=56 58 | .[56]=57 59 | .[57]=58 60 | .[58]=59 61 | .[59]=60 62 | .[60]=61 63 | .[61]=62 64 | .[62]=63 65 | .[63]=64 66 | .[64]=65 67 | .[65]=66 68 | .[66]=67 69 | .[67]=68 70 | .[68]=69 71 | .[69]=70 72 | .[70]=71 73 | .[71]=72 74 | .[72]=73 75 | .[73]=74 76 | .[74]=75 77 | .[75]=76 78 | .[76]=77 79 | .[77]=78 80 | .[78]=79 81 | .[79]=80 82 | .[80]=81 83 | .[81]=82 84 | .[82]=83 85 | .[83]=84 86 | .[84]=85 87 | .[85]=86 88 | .[86]=87 89 | .[87]=88 90 | .[88]=89 91 | .[89]=90 92 | .[90]=91 93 | .[91]=92 94 | .[92]=93 95 | .[93]=94 96 | .[94]=95 97 | .[95]=96 98 | .[96]=97 99 | .[97]=98 100 | .[98]=99 101 | -------------------------------------------------------------------------------- /test/data/test_array_05.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | .[1]=2 4 | .[2]=3 5 | .[3]=4 6 | .[4]=5 7 | .[5]=6 8 | .[6]=7 9 | .[7]=8 10 | .[8]=9 11 | .[9]=10 12 | .[10]=11 13 | .[11]=12 14 | .[12]=13 15 | .[13]=14 16 | .[14]=15 17 | .[15]=16 18 | .[16]=17 19 | .[17]=18 20 | .[18]=19 21 | .[19]=20 22 | .[20]=21 23 | .[21]=22 24 | .[22]=23 25 | .[23]=24 26 | .[24]=25 27 | .[25]=26 28 | .[26]=27 29 | .[27]=28 30 | .[28]=29 31 | .[29]=30 32 | .[30]=31 33 | .[31]=32 34 | .[32]=33 35 | .[33]=34 36 | .[34]=35 37 | .[35]=36 38 | .[36]=37 39 | .[37]=38 40 | .[38]=39 41 | .[39]=40 42 | .[40]=41 43 | .[41]=42 44 | .[42]=43 45 | .[43]=44 46 | .[44]=45 47 | .[45]=46 48 | .[46]=47 49 | .[47]=48 50 | .[48]=49 51 | .[49]=50 52 | .[50]=51 53 | .[51]=52 54 | .[52]=53 55 | .[53]=54 56 | .[54]=55 57 | .[55]=56 58 | .[56]=57 59 | .[57]=58 60 | .[58]=59 61 | .[59]=60 62 | .[60]=61 63 | .[61]=62 64 | .[62]=63 65 | .[63]=64 66 | .[64]=65 67 | .[65]=66 68 | .[66]=67 69 | .[67]=68 70 | .[68]=69 71 | .[69]=70 72 | .[70]=71 73 | .[71]=72 74 | .[72]=73 75 | .[73]=74 76 | .[74]=75 77 | .[75]=76 78 | .[76]=77 79 | .[77]=78 80 | .[78]=79 81 | .[79]=80 82 | .[80]=81 83 | .[81]=82 84 | .[82]=83 85 | .[83]=84 86 | .[84]=85 87 | .[85]=86 88 | .[86]=87 89 | .[87]=88 90 | .[88]=89 91 | .[89]=90 92 | .[90]=91 93 | .[91]=92 94 | .[92]=93 95 | .[93]=94 96 | .[94]=95 97 | .[95]=96 98 | .[96]=97 99 | .[97]=98 100 | .[98]=99 101 | -------------------------------------------------------------------------------- /test/data/test_array_05.expected: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]=1 3 | .[1]=2 4 | .[2]=3 5 | .[3]=4 6 | .[4]=5 7 | .[5]=6 8 | .[6]=7 9 | .[7]=8 10 | .[8]=9 11 | .[9]=10 12 | .[10]=11 13 | .[11]=12 14 | .[12]=13 15 | .[13]=14 16 | .[14]=15 17 | .[15]=16 18 | .[16]=17 19 | .[17]=18 20 | .[18]=19 21 | .[19]=20 22 | .[20]=21 23 | .[21]=22 24 | .[22]=23 25 | .[23]=24 26 | .[24]=25 27 | .[25]=26 28 | .[26]=27 29 | .[27]=28 30 | .[28]=29 31 | .[29]=30 32 | .[30]=31 33 | .[31]=32 34 | .[32]=33 35 | .[33]=34 36 | .[34]=35 37 | .[35]=36 38 | .[36]=37 39 | .[37]=38 40 | .[38]=39 41 | .[39]=40 42 | .[40]=41 43 | .[41]=42 44 | .[42]=43 45 | .[43]=44 46 | .[44]=45 47 | .[45]=46 48 | .[46]=47 49 | .[47]=48 50 | .[48]=49 51 | .[49]=50 52 | .[50]=51 53 | .[51]=52 54 | .[52]=53 55 | .[53]=54 56 | .[54]=55 57 | .[55]=56 58 | .[56]=57 59 | .[57]=58 60 | .[58]=59 61 | .[59]=60 62 | .[60]=61 63 | .[61]=62 64 | .[62]=63 65 | .[63]=64 66 | .[64]=65 67 | .[65]=66 68 | .[66]=67 69 | .[67]=68 70 | .[68]=69 71 | .[69]=70 72 | .[70]=71 73 | .[71]=72 74 | .[72]=73 75 | .[73]=74 76 | .[74]=75 77 | .[75]=76 78 | .[76]=77 79 | .[77]=78 80 | .[78]=79 81 | .[79]=80 82 | .[80]=81 83 | .[81]=82 84 | .[82]=83 85 | .[83]=84 86 | .[84]=85 87 | .[85]=86 88 | .[86]=87 89 | .[87]=88 90 | .[88]=89 91 | .[89]=90 92 | .[90]=91 93 | .[91]=92 94 | .[92]=93 95 | .[93]=94 96 | .[94]=95 97 | .[95]=96 98 | .[96]=97 99 | .[97]=98 100 | .[98]=99 101 | -------------------------------------------------------------------------------- /test/data/test_array_05.json: -------------------------------------------------------------------------------- 1 | [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99] -------------------------------------------------------------------------------- /test/data/test_array_05.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_array_05.process-output -------------------------------------------------------------------------------- /test/data/test_array_05.rewrite: -------------------------------------------------------------------------------- 1 | [ 2 | 1, 3 | 2, 4 | 3, 5 | 4, 6 | 5, 7 | 6, 8 | 7, 9 | 8, 10 | 9, 11 | 10, 12 | 11, 13 | 12, 14 | 13, 15 | 14, 16 | 15, 17 | 16, 18 | 17, 19 | 18, 20 | 19, 21 | 20, 22 | 21, 23 | 22, 24 | 23, 25 | 24, 26 | 25, 27 | 26, 28 | 27, 29 | 28, 30 | 29, 31 | 30, 32 | 31, 33 | 32, 34 | 33, 35 | 34, 36 | 35, 37 | 36, 38 | 37, 39 | 38, 40 | 39, 41 | 40, 42 | 41, 43 | 42, 44 | 43, 45 | 44, 46 | 45, 47 | 46, 48 | 47, 49 | 48, 50 | 49, 51 | 50, 52 | 51, 53 | 52, 54 | 53, 55 | 54, 56 | 55, 57 | 56, 58 | 57, 59 | 58, 60 | 59, 61 | 60, 62 | 61, 63 | 62, 64 | 63, 65 | 64, 66 | 65, 67 | 66, 68 | 67, 69 | 68, 70 | 69, 71 | 70, 72 | 71, 73 | 72, 74 | 73, 75 | 74, 76 | 75, 77 | 76, 78 | 77, 79 | 78, 80 | 79, 81 | 80, 82 | 81, 83 | 82, 84 | 83, 85 | 84, 86 | 85, 87 | 86, 88 | 87, 89 | 88, 90 | 89, 91 | 90, 92 | 91, 93 | 92, 94 | 93, 95 | 94, 96 | 95, 97 | 96, 98 | 97, 99 | 98, 100 | 99 101 | ] 102 | 103 | -------------------------------------------------------------------------------- /test/data/test_array_06.actual: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 3 | .[1]="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 4 | .[2]="ccccccccccccccccccccccc" 5 | .[3]="dddddddddddddddddddddddddddddddddddddddddddddddddddd" 6 | -------------------------------------------------------------------------------- /test/data/test_array_06.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 3 | .[1]="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 4 | .[2]="ccccccccccccccccccccccc" 5 | .[3]="dddddddddddddddddddddddddddddddddddddddddddddddddddd" 6 | -------------------------------------------------------------------------------- /test/data/test_array_06.expected: -------------------------------------------------------------------------------- 1 | .=[] 2 | .[0]="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 3 | .[1]="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 4 | .[2]="ccccccccccccccccccccccc" 5 | .[3]="dddddddddddddddddddddddddddddddddddddddddddddddddddd" 6 | -------------------------------------------------------------------------------- /test/data/test_array_06.json: -------------------------------------------------------------------------------- 1 | [ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 2 | "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 3 | "ccccccccccccccccccccccc", 4 | "dddddddddddddddddddddddddddddddddddddddddddddddddddd" ] -------------------------------------------------------------------------------- /test/data/test_array_06.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_array_06.process-output -------------------------------------------------------------------------------- /test/data/test_array_06.rewrite: -------------------------------------------------------------------------------- 1 | [ 2 | "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 3 | "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 4 | "ccccccccccccccccccccccc", 5 | "dddddddddddddddddddddddddddddddddddddddddddddddddddd" 6 | ] 7 | 8 | -------------------------------------------------------------------------------- /test/data/test_basic_01.actual: -------------------------------------------------------------------------------- 1 | .=123456789 2 | -------------------------------------------------------------------------------- /test/data/test_basic_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=123456789 2 | -------------------------------------------------------------------------------- /test/data/test_basic_01.expected: -------------------------------------------------------------------------------- 1 | .=123456789 2 | -------------------------------------------------------------------------------- /test/data/test_basic_01.json: -------------------------------------------------------------------------------- 1 | 0123456789 2 | -------------------------------------------------------------------------------- /test/data/test_basic_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_basic_01.process-output -------------------------------------------------------------------------------- /test/data/test_basic_01.rewrite: -------------------------------------------------------------------------------- 1 | 123456789 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_02.actual: -------------------------------------------------------------------------------- 1 | .=-123456789 2 | -------------------------------------------------------------------------------- /test/data/test_basic_02.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=-123456789 2 | -------------------------------------------------------------------------------- /test/data/test_basic_02.expected: -------------------------------------------------------------------------------- 1 | .=-123456789 2 | -------------------------------------------------------------------------------- /test/data/test_basic_02.json: -------------------------------------------------------------------------------- 1 | -0123456789 2 | -------------------------------------------------------------------------------- /test/data/test_basic_02.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_basic_02.process-output -------------------------------------------------------------------------------- /test/data/test_basic_02.rewrite: -------------------------------------------------------------------------------- 1 | -123456789 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_03.actual: -------------------------------------------------------------------------------- 1 | .=1.2345678 2 | -------------------------------------------------------------------------------- /test/data/test_basic_03.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=1.2345678 2 | -------------------------------------------------------------------------------- /test/data/test_basic_03.expected: -------------------------------------------------------------------------------- 1 | .=1.2345678 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_basic_03.json: -------------------------------------------------------------------------------- 1 | 1.2345678 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_basic_03.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_basic_03.process-output -------------------------------------------------------------------------------- /test/data/test_basic_03.rewrite: -------------------------------------------------------------------------------- 1 | 1.23456780 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_04.actual: -------------------------------------------------------------------------------- 1 | .="abcdef" 2 | -------------------------------------------------------------------------------- /test/data/test_basic_04.actual-rewrite: -------------------------------------------------------------------------------- 1 | .="abcdef" 2 | -------------------------------------------------------------------------------- /test/data/test_basic_04.expected: -------------------------------------------------------------------------------- 1 | .="abcdef" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_04.json: -------------------------------------------------------------------------------- 1 | "abcdef" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_04.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_basic_04.process-output -------------------------------------------------------------------------------- /test/data/test_basic_04.rewrite: -------------------------------------------------------------------------------- 1 | "abcdef" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_05.actual: -------------------------------------------------------------------------------- 1 | .=null 2 | -------------------------------------------------------------------------------- /test/data/test_basic_05.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=null 2 | -------------------------------------------------------------------------------- /test/data/test_basic_05.expected: -------------------------------------------------------------------------------- 1 | .=null 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_05.json: -------------------------------------------------------------------------------- 1 | null 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_05.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_basic_05.process-output -------------------------------------------------------------------------------- /test/data/test_basic_05.rewrite: -------------------------------------------------------------------------------- 1 | null 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_06.actual: -------------------------------------------------------------------------------- 1 | .=true 2 | -------------------------------------------------------------------------------- /test/data/test_basic_06.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=true 2 | -------------------------------------------------------------------------------- /test/data/test_basic_06.expected: -------------------------------------------------------------------------------- 1 | .=true 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_06.json: -------------------------------------------------------------------------------- 1 | true 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_06.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_basic_06.process-output -------------------------------------------------------------------------------- /test/data/test_basic_06.rewrite: -------------------------------------------------------------------------------- 1 | true 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_07.actual: -------------------------------------------------------------------------------- 1 | .=false 2 | -------------------------------------------------------------------------------- /test/data/test_basic_07.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=false 2 | -------------------------------------------------------------------------------- /test/data/test_basic_07.expected: -------------------------------------------------------------------------------- 1 | .=false 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_07.json: -------------------------------------------------------------------------------- 1 | false 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_07.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_basic_07.process-output -------------------------------------------------------------------------------- /test/data/test_basic_07.rewrite: -------------------------------------------------------------------------------- 1 | false 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_08.actual: -------------------------------------------------------------------------------- 1 | .=null 2 | -------------------------------------------------------------------------------- /test/data/test_basic_08.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=null 2 | -------------------------------------------------------------------------------- /test/data/test_basic_08.expected: -------------------------------------------------------------------------------- 1 | .=null 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_08.json: -------------------------------------------------------------------------------- 1 | // C++ style comment 2 | null 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_basic_08.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_basic_08.process-output -------------------------------------------------------------------------------- /test/data/test_basic_08.rewrite: -------------------------------------------------------------------------------- 1 | // C++ style comment 2 | 3 | null 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_basic_09.actual: -------------------------------------------------------------------------------- 1 | .=null 2 | -------------------------------------------------------------------------------- /test/data/test_basic_09.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=null 2 | -------------------------------------------------------------------------------- /test/data/test_basic_09.expected: -------------------------------------------------------------------------------- 1 | .=null 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_basic_09.json: -------------------------------------------------------------------------------- 1 | /* C style comment 2 | */ 3 | null 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_basic_09.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_basic_09.process-output -------------------------------------------------------------------------------- /test/data/test_basic_09.rewrite: -------------------------------------------------------------------------------- 1 | /* C style comment 2 | */ 3 | null 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_comment_01.actual: -------------------------------------------------------------------------------- 1 | .={} 2 | .test=[] 3 | .test[0]={} 4 | .test[0].a="aaa" 5 | .test[1]={} 6 | .test[1].b="bbb" 7 | .test[2]={} 8 | .test[2].c="ccc" 9 | -------------------------------------------------------------------------------- /test/data/test_comment_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .={} 2 | .test=[] 3 | .test[0]={} 4 | .test[0].a="aaa" 5 | .test[1]={} 6 | .test[1].b="bbb" 7 | .test[2]={} 8 | .test[2].c="ccc" 9 | -------------------------------------------------------------------------------- /test/data/test_comment_01.expected: -------------------------------------------------------------------------------- 1 | .={} 2 | .test=[] 3 | .test[0]={} 4 | .test[0].a="aaa" 5 | .test[1]={} 6 | .test[1].b="bbb" 7 | .test[2]={} 8 | .test[2].c="ccc" 9 | -------------------------------------------------------------------------------- /test/data/test_comment_01.json: -------------------------------------------------------------------------------- 1 | { 2 | "test": 3 | [ 4 | { "a" : "aaa" }, // Comment for a 5 | { "b" : "bbb" }, // Comment for b 6 | { "c" : "ccc" } // Comment for c 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /test/data/test_comment_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_comment_01.process-output -------------------------------------------------------------------------------- /test/data/test_comment_01.rewrite: -------------------------------------------------------------------------------- 1 | { 2 | "test" : [ 3 | { 4 | "a" : "aaa" 5 | }, // Comment for a 6 | { 7 | "b" : "bbb" 8 | }, // Comment for b 9 | { 10 | "c" : "ccc" 11 | } // Comment for c 12 | ] 13 | } 14 | 15 | -------------------------------------------------------------------------------- /test/data/test_complex_01.actual: -------------------------------------------------------------------------------- 1 | .={} 2 | .attribute=[] 3 | .attribute[0]="random" 4 | .attribute[1]="short" 5 | .attribute[2]="bold" 6 | .attribute[3]=12 7 | .attribute[4]={} 8 | .attribute[4].height=7 9 | .attribute[4].width=64 10 | .count=1234 11 | .name={} 12 | .name.aka="T.E.S.T." 13 | .name.id=123987 14 | .test={} 15 | .test.1={} 16 | .test.1.2={} 17 | .test.1.2.3={} 18 | .test.1.2.3.coord=[] 19 | .test.1.2.3.coord[0]=1 20 | .test.1.2.3.coord[1]=2 21 | -------------------------------------------------------------------------------- /test/data/test_complex_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .={} 2 | .attribute=[] 3 | .attribute[0]="random" 4 | .attribute[1]="short" 5 | .attribute[2]="bold" 6 | .attribute[3]=12 7 | .attribute[4]={} 8 | .attribute[4].height=7 9 | .attribute[4].width=64 10 | .count=1234 11 | .name={} 12 | .name.aka="T.E.S.T." 13 | .name.id=123987 14 | .test={} 15 | .test.1={} 16 | .test.1.2={} 17 | .test.1.2.3={} 18 | .test.1.2.3.coord=[] 19 | .test.1.2.3.coord[0]=1 20 | .test.1.2.3.coord[1]=2 21 | -------------------------------------------------------------------------------- /test/data/test_complex_01.expected: -------------------------------------------------------------------------------- 1 | .={} 2 | .attribute=[] 3 | .attribute[0]="random" 4 | .attribute[1]="short" 5 | .attribute[2]="bold" 6 | .attribute[3]=12 7 | .attribute[4]={} 8 | .attribute[4].height=7 9 | .attribute[4].width=64 10 | .count=1234 11 | .name={} 12 | .name.aka="T.E.S.T." 13 | .name.id=123987 14 | .test={} 15 | .test.1={} 16 | .test.1.2={} 17 | .test.1.2.3={} 18 | .test.1.2.3.coord=[] 19 | .test.1.2.3.coord[0]=1 20 | .test.1.2.3.coord[1]=2 21 | -------------------------------------------------------------------------------- /test/data/test_complex_01.json: -------------------------------------------------------------------------------- 1 | { 2 | "count" : 1234, 3 | "name" : { "aka" : "T.E.S.T.", "id" : 123987 }, 4 | "attribute" : [ 5 | "random", 6 | "short", 7 | "bold", 8 | 12, 9 | { "height" : 7, "width" : 64 } 10 | ], 11 | "test": { "1" : 12 | { "2" : 13 | { "3" : { "coord" : [ 1,2] } 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/data/test_complex_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_complex_01.process-output -------------------------------------------------------------------------------- /test/data/test_complex_01.rewrite: -------------------------------------------------------------------------------- 1 | { 2 | "attribute" : [ 3 | "random", 4 | "short", 5 | "bold", 6 | 12, 7 | { 8 | "height" : 7, 9 | "width" : 64 10 | } 11 | ], 12 | "count" : 1234, 13 | "name" : { 14 | "aka" : "T.E.S.T.", 15 | "id" : 123987 16 | }, 17 | "test" : { 18 | "1" : { 19 | "2" : { 20 | "3" : { 21 | "coord" : [ 1, 2 ] 22 | } 23 | } 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /test/data/test_integer_01.actual: -------------------------------------------------------------------------------- 1 | .=2147483647 2 | -------------------------------------------------------------------------------- /test/data/test_integer_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=2147483647 2 | -------------------------------------------------------------------------------- /test/data/test_integer_01.expected: -------------------------------------------------------------------------------- 1 | .=2147483647 2 | -------------------------------------------------------------------------------- /test/data/test_integer_01.json: -------------------------------------------------------------------------------- 1 | // Max signed integer 2 | 2147483647 3 | -------------------------------------------------------------------------------- /test/data/test_integer_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_integer_01.process-output -------------------------------------------------------------------------------- /test/data/test_integer_01.rewrite: -------------------------------------------------------------------------------- 1 | // Max signed integer 2 | 3 | 2147483647 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_integer_02.actual: -------------------------------------------------------------------------------- 1 | .=-2147483648 2 | -------------------------------------------------------------------------------- /test/data/test_integer_02.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=-2147483648 2 | -------------------------------------------------------------------------------- /test/data/test_integer_02.expected: -------------------------------------------------------------------------------- 1 | .=-2147483648 2 | -------------------------------------------------------------------------------- /test/data/test_integer_02.json: -------------------------------------------------------------------------------- 1 | // Min signed integer 2 | -2147483648 3 | -------------------------------------------------------------------------------- /test/data/test_integer_02.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_integer_02.process-output -------------------------------------------------------------------------------- /test/data/test_integer_02.rewrite: -------------------------------------------------------------------------------- 1 | // Min signed integer 2 | 3 | -2147483648.0 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_integer_03.actual: -------------------------------------------------------------------------------- 1 | .=4294967295 2 | -------------------------------------------------------------------------------- /test/data/test_integer_03.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=4294967295 2 | -------------------------------------------------------------------------------- /test/data/test_integer_03.expected: -------------------------------------------------------------------------------- 1 | .=4294967295 2 | -------------------------------------------------------------------------------- /test/data/test_integer_03.json: -------------------------------------------------------------------------------- 1 | // Max unsigned integer 2 | 4294967295 3 | -------------------------------------------------------------------------------- /test/data/test_integer_03.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_integer_03.process-output -------------------------------------------------------------------------------- /test/data/test_integer_03.rewrite: -------------------------------------------------------------------------------- 1 | // Max unsigned integer 2 | 3 | 4294967295.0 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_integer_04.actual: -------------------------------------------------------------------------------- 1 | .=0 2 | -------------------------------------------------------------------------------- /test/data/test_integer_04.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=0 2 | -------------------------------------------------------------------------------- /test/data/test_integer_04.expected: -------------------------------------------------------------------------------- 1 | .=0 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_integer_04.json: -------------------------------------------------------------------------------- 1 | // Min unsigned integer 2 | 0 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_integer_04.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_integer_04.process-output -------------------------------------------------------------------------------- /test/data/test_integer_04.rewrite: -------------------------------------------------------------------------------- 1 | // Min unsigned integer 2 | 3 | 0 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_integer_05.actual: -------------------------------------------------------------------------------- 1 | .=1 2 | -------------------------------------------------------------------------------- /test/data/test_integer_05.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=1 2 | -------------------------------------------------------------------------------- /test/data/test_integer_05.expected: -------------------------------------------------------------------------------- 1 | .=1 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_integer_05.json: -------------------------------------------------------------------------------- 1 | 1 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_integer_05.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_integer_05.process-output -------------------------------------------------------------------------------- /test/data/test_integer_05.rewrite: -------------------------------------------------------------------------------- 1 | 1 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_large_01.json: -------------------------------------------------------------------------------- 1 | [["A",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1150,1151,1152,1153,1154,1155,1156,1157,1158,1159,1160,1161,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1325,1326,1327,1328,1329,1330,1331,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1361,1362,1363,1364,1365,1366,1367,1368,1369,1370,1371,1372,1373,1374,1375,1376,1377,1378,1379,1380,1381,1382,1383,1384,1385,1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1406,1407,1408,1409,1410,1411,1412,1413,1414,1415,1416,1417,1418,1419,1420,1421,1422,1423,1424,1425,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477,1478,1479,1480,1481,1482,1483,1484,1485,1486,1487,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1515,1516,1517,1518,1519,1520,1521,1522,1523,1524,1525,1526,1527,1528,1529,1530,1531,1532,1533,1534,1535,1536,1537,1538,1539,1540,1541,1542,1543,1544,1545,1546,1547,1548,1549,1550,1551,1552,1553,1554,1555,1556,1557,1558,1559,1560,1561,1562,1563,1564,1565,1566,1567,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,1617,1618,1619,1620,1621,1622,1623,1624,1625,1626,1627,1628,1629,1630,1631,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,1642,1643,1644,1645,1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1748,1749,1750,1751,1752,1753,1754,1755,1756,1757,1758,1759,1760,1761,1762,1763,1764,1765,1766,1767,1768,1769,1770,1771,1772,1773,1774,1775,1776,1777,1778,1779,1780,1781,1782,1783,1784,1785,1786,1787,1788,1789,1790,1791,1792,1793,1794,1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1806,1807,1808,1809,1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1840,1841,1842,1843,1844,1845,1846,1847,1848,1849,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1861,1862,1863,1864,1865,1866,1867,1868,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2070,2071,2072,2073,2074,2075,2076,2077,2078,2079,2080,2081,2082,2083,2084,2085,2086,2087,2088,2089,2090,2091,2092,2093,2094,2095,2096,2097,2098,2099,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2111,2112,2113,2114,2115,2116,2117,2118] 2 | ] -------------------------------------------------------------------------------- /test/data/test_large_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_large_01.process-output -------------------------------------------------------------------------------- /test/data/test_object_01.actual: -------------------------------------------------------------------------------- 1 | .={} 2 | -------------------------------------------------------------------------------- /test/data/test_object_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .={} 2 | -------------------------------------------------------------------------------- /test/data/test_object_01.expected: -------------------------------------------------------------------------------- 1 | .={} 2 | -------------------------------------------------------------------------------- /test/data/test_object_01.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/data/test_object_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_object_01.process-output -------------------------------------------------------------------------------- /test/data/test_object_01.rewrite: -------------------------------------------------------------------------------- 1 | {} 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_object_02.actual: -------------------------------------------------------------------------------- 1 | .={} 2 | .count=1234 3 | -------------------------------------------------------------------------------- /test/data/test_object_02.actual-rewrite: -------------------------------------------------------------------------------- 1 | .={} 2 | .count=1234 3 | -------------------------------------------------------------------------------- /test/data/test_object_02.expected: -------------------------------------------------------------------------------- 1 | .={} 2 | .count=1234 3 | -------------------------------------------------------------------------------- /test/data/test_object_02.json: -------------------------------------------------------------------------------- 1 | { "count" : 1234 } 2 | -------------------------------------------------------------------------------- /test/data/test_object_02.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_object_02.process-output -------------------------------------------------------------------------------- /test/data/test_object_02.rewrite: -------------------------------------------------------------------------------- 1 | { 2 | "count" : 1234 3 | } 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_object_03.actual: -------------------------------------------------------------------------------- 1 | .={} 2 | .attribute="random" 3 | .count=1234 4 | .name="test" 5 | -------------------------------------------------------------------------------- /test/data/test_object_03.actual-rewrite: -------------------------------------------------------------------------------- 1 | .={} 2 | .attribute="random" 3 | .count=1234 4 | .name="test" 5 | -------------------------------------------------------------------------------- /test/data/test_object_03.expected: -------------------------------------------------------------------------------- 1 | .={} 2 | .attribute="random" 3 | .count=1234 4 | .name="test" 5 | -------------------------------------------------------------------------------- /test/data/test_object_03.json: -------------------------------------------------------------------------------- 1 | { 2 | "count" : 1234, 3 | "name" : "test", 4 | "attribute" : "random" 5 | } 6 | -------------------------------------------------------------------------------- /test/data/test_object_03.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_object_03.process-output -------------------------------------------------------------------------------- /test/data/test_object_03.rewrite: -------------------------------------------------------------------------------- 1 | { 2 | "attribute" : "random", 3 | "count" : 1234, 4 | "name" : "test" 5 | } 6 | 7 | -------------------------------------------------------------------------------- /test/data/test_object_04.actual: -------------------------------------------------------------------------------- 1 | .={} 2 | .=1234 3 | -------------------------------------------------------------------------------- /test/data/test_object_04.actual-rewrite: -------------------------------------------------------------------------------- 1 | .={} 2 | .=1234 3 | -------------------------------------------------------------------------------- /test/data/test_object_04.expected: -------------------------------------------------------------------------------- 1 | .={} 2 | .=1234 3 | -------------------------------------------------------------------------------- /test/data/test_object_04.json: -------------------------------------------------------------------------------- 1 | { 2 | "" : 1234 3 | } 4 | -------------------------------------------------------------------------------- /test/data/test_object_04.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_object_04.process-output -------------------------------------------------------------------------------- /test/data/test_object_04.rewrite: -------------------------------------------------------------------------------- 1 | { 2 | "" : 1234 3 | } 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_preserve_comment_01.actual: -------------------------------------------------------------------------------- 1 | .={} 2 | .first=1 3 | .second=2 4 | -------------------------------------------------------------------------------- /test/data/test_preserve_comment_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .={} 2 | .first=1 3 | .second=2 4 | -------------------------------------------------------------------------------- /test/data/test_preserve_comment_01.expected: -------------------------------------------------------------------------------- 1 | .={} 2 | .first=1 3 | .second=2 4 | -------------------------------------------------------------------------------- /test/data/test_preserve_comment_01.json: -------------------------------------------------------------------------------- 1 | /* A comment 2 | at the beginning of the file. 3 | */ 4 | { 5 | "first" : 1, // comment after 'first' on the same line 6 | 7 | /* Comment before 'second' 8 | */ 9 | "second" : 2 10 | } 11 | 12 | /* A comment at 13 | the end of the file. 14 | */ 15 | -------------------------------------------------------------------------------- /test/data/test_preserve_comment_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_preserve_comment_01.process-output -------------------------------------------------------------------------------- /test/data/test_preserve_comment_01.rewrite: -------------------------------------------------------------------------------- 1 | /* A comment 2 | at the beginning of the file. 3 | */ 4 | { 5 | "first" : 1, // comment after 'first' on the same line 6 | /* Comment before 'second' 7 | */ 8 | "second" : 2 9 | } 10 | /* A comment at 11 | the end of the file. 12 | */ 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/data/test_real_01.actual: -------------------------------------------------------------------------------- 1 | .=8589934592 2 | -------------------------------------------------------------------------------- /test/data/test_real_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=8589934592 2 | -------------------------------------------------------------------------------- /test/data/test_real_01.expected: -------------------------------------------------------------------------------- 1 | .=8589934592 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_real_01.json: -------------------------------------------------------------------------------- 1 | // 2^33 => out of integer range, switch to double 2 | 8589934592 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_real_01.process-output -------------------------------------------------------------------------------- /test/data/test_real_01.rewrite: -------------------------------------------------------------------------------- 1 | // 2^33 => out of integer range, switch to double 2 | 3 | 8589934592.0 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_real_02.actual: -------------------------------------------------------------------------------- 1 | .=-4294967295 2 | -------------------------------------------------------------------------------- /test/data/test_real_02.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=-4294967295 2 | -------------------------------------------------------------------------------- /test/data/test_real_02.expected: -------------------------------------------------------------------------------- 1 | .=-4294967295 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_real_02.json: -------------------------------------------------------------------------------- 1 | // -2^32 => out of signed integer range, switch to double 2 | -4294967295 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_02.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_real_02.process-output -------------------------------------------------------------------------------- /test/data/test_real_02.rewrite: -------------------------------------------------------------------------------- 1 | // -2^32 => out of signed integer range, switch to double 2 | 3 | -4294967295.0 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_real_03.actual: -------------------------------------------------------------------------------- 1 | .=-4294967295 2 | -------------------------------------------------------------------------------- /test/data/test_real_03.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=-4294967295 2 | -------------------------------------------------------------------------------- /test/data/test_real_03.expected: -------------------------------------------------------------------------------- 1 | .=-4294967295 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_real_03.json: -------------------------------------------------------------------------------- 1 | // -2^32 => out of signed integer range, switch to double 2 | -4294967295 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_03.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_real_03.process-output -------------------------------------------------------------------------------- /test/data/test_real_03.rewrite: -------------------------------------------------------------------------------- 1 | // -2^32 => out of signed integer range, switch to double 2 | 3 | -4294967295.0 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_real_04.actual: -------------------------------------------------------------------------------- 1 | .=1.2345678 2 | -------------------------------------------------------------------------------- /test/data/test_real_04.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=1.2345678 2 | -------------------------------------------------------------------------------- /test/data/test_real_04.expected: -------------------------------------------------------------------------------- 1 | .=1.2345678 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_real_04.json: -------------------------------------------------------------------------------- 1 | // 1.2345678 2 | 12345678e-7 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_04.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_real_04.process-output -------------------------------------------------------------------------------- /test/data/test_real_04.rewrite: -------------------------------------------------------------------------------- 1 | // 1.2345678 2 | 3 | 1.23456780 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_real_05.actual: -------------------------------------------------------------------------------- 1 | .=1234567.8 2 | -------------------------------------------------------------------------------- /test/data/test_real_05.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=1234567.8 2 | -------------------------------------------------------------------------------- /test/data/test_real_05.expected: -------------------------------------------------------------------------------- 1 | .=1234567.8 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_05.json: -------------------------------------------------------------------------------- 1 | // 1234567.8 2 | 0.12345678e7 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_05.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_real_05.process-output -------------------------------------------------------------------------------- /test/data/test_real_05.rewrite: -------------------------------------------------------------------------------- 1 | // 1234567.8 2 | 3 | 1234567.80 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_real_06.actual: -------------------------------------------------------------------------------- 1 | .=-1.2345678 2 | -------------------------------------------------------------------------------- /test/data/test_real_06.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=-1.2345678 2 | -------------------------------------------------------------------------------- /test/data/test_real_06.expected: -------------------------------------------------------------------------------- 1 | .=-1.2345678 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_06.json: -------------------------------------------------------------------------------- 1 | // -1.2345678 2 | -12345678e-7 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_06.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_real_06.process-output -------------------------------------------------------------------------------- /test/data/test_real_06.rewrite: -------------------------------------------------------------------------------- 1 | // -1.2345678 2 | 3 | -1.23456780 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_real_07.actual: -------------------------------------------------------------------------------- 1 | .=-1234567.8 2 | -------------------------------------------------------------------------------- /test/data/test_real_07.actual-rewrite: -------------------------------------------------------------------------------- 1 | .=-1234567.8 2 | -------------------------------------------------------------------------------- /test/data/test_real_07.expected: -------------------------------------------------------------------------------- 1 | .=-1234567.8 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_07.json: -------------------------------------------------------------------------------- 1 | // -1234567.8 2 | -0.12345678e7 3 | 4 | -------------------------------------------------------------------------------- /test/data/test_real_07.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_real_07.process-output -------------------------------------------------------------------------------- /test/data/test_real_07.rewrite: -------------------------------------------------------------------------------- 1 | // -1234567.8 2 | 3 | -1234567.80 4 | 5 | -------------------------------------------------------------------------------- /test/data/test_string_01.actual: -------------------------------------------------------------------------------- 1 | .="!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 2 | -------------------------------------------------------------------------------- /test/data/test_string_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .="!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 2 | -------------------------------------------------------------------------------- /test/data/test_string_01.expected: -------------------------------------------------------------------------------- 1 | .="!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" -------------------------------------------------------------------------------- /test/data/test_string_01.json: -------------------------------------------------------------------------------- 1 | "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 2 | -------------------------------------------------------------------------------- /test/data/test_string_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_string_01.process-output -------------------------------------------------------------------------------- /test/data/test_string_01.rewrite: -------------------------------------------------------------------------------- 1 | "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_string_02.actual: -------------------------------------------------------------------------------- 1 | .="!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 2 | -------------------------------------------------------------------------------- /test/data/test_string_02.actual-rewrite: -------------------------------------------------------------------------------- 1 | .="!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 2 | -------------------------------------------------------------------------------- /test/data/test_string_02.expected: -------------------------------------------------------------------------------- 1 | .="!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" -------------------------------------------------------------------------------- /test/data/test_string_02.json: -------------------------------------------------------------------------------- 1 | "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 2 | -------------------------------------------------------------------------------- /test/data/test_string_02.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_string_02.process-output -------------------------------------------------------------------------------- /test/data/test_string_02.rewrite: -------------------------------------------------------------------------------- 1 | "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_01.actual: -------------------------------------------------------------------------------- 1 | .="a" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_01.actual-rewrite: -------------------------------------------------------------------------------- 1 | .="a" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_01.expected: -------------------------------------------------------------------------------- 1 | .="a" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_01.json: -------------------------------------------------------------------------------- 1 | "\u0061" -------------------------------------------------------------------------------- /test/data/test_string_unicode_01.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_string_unicode_01.process-output -------------------------------------------------------------------------------- /test/data/test_string_unicode_01.rewrite: -------------------------------------------------------------------------------- 1 | "a" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_02.actual: -------------------------------------------------------------------------------- 1 | .="¢" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_02.actual-rewrite: -------------------------------------------------------------------------------- 1 | .="¢" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_02.expected: -------------------------------------------------------------------------------- 1 | .="¢" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_02.json: -------------------------------------------------------------------------------- 1 | "\u00A2" -------------------------------------------------------------------------------- /test/data/test_string_unicode_02.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_string_unicode_02.process-output -------------------------------------------------------------------------------- /test/data/test_string_unicode_02.rewrite: -------------------------------------------------------------------------------- 1 | "¢" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_03.actual: -------------------------------------------------------------------------------- 1 | .="€" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_03.actual-rewrite: -------------------------------------------------------------------------------- 1 | .="€" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_03.expected: -------------------------------------------------------------------------------- 1 | .="€" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_03.json: -------------------------------------------------------------------------------- 1 | "\u20AC" -------------------------------------------------------------------------------- /test/data/test_string_unicode_03.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_string_unicode_03.process-output -------------------------------------------------------------------------------- /test/data/test_string_unicode_03.rewrite: -------------------------------------------------------------------------------- 1 | "€" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_04.actual: -------------------------------------------------------------------------------- 1 | .="𝄞" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_04.actual-rewrite: -------------------------------------------------------------------------------- 1 | .="𝄞" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_04.expected: -------------------------------------------------------------------------------- 1 | .="𝄞" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_04.json: -------------------------------------------------------------------------------- 1 | "\uD834\uDD1E" -------------------------------------------------------------------------------- /test/data/test_string_unicode_04.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_string_unicode_04.process-output -------------------------------------------------------------------------------- /test/data/test_string_unicode_04.rewrite: -------------------------------------------------------------------------------- 1 | "𝄞" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_05.actual: -------------------------------------------------------------------------------- 1 | .="Zażółć gęślą jaźń" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_05.actual-rewrite: -------------------------------------------------------------------------------- 1 | .="Zażółć gęślą jaźń" 2 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_05.expected: -------------------------------------------------------------------------------- 1 | .="Zażółć gęślą jaźń" 2 | 3 | -------------------------------------------------------------------------------- /test/data/test_string_unicode_05.json: -------------------------------------------------------------------------------- 1 | "Zażółć gęślą jaźń" -------------------------------------------------------------------------------- /test/data/test_string_unicode_05.process-output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/data/test_string_unicode_05.process-output -------------------------------------------------------------------------------- /test/data/test_string_unicode_05.rewrite: -------------------------------------------------------------------------------- 1 | "Zażółć gęślą jaźń" 2 | 3 | -------------------------------------------------------------------------------- /test/generate_expected.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import os.path 3 | for path in glob.glob( '*.json' ): 4 | text = file(path,'rt').read() 5 | target = os.path.splitext(path)[0] + '.expected' 6 | if os.path.exists( target ): 7 | print 'skipping:', target 8 | else: 9 | print 'creating:', target 10 | file(target,'wt').write(text) 11 | 12 | -------------------------------------------------------------------------------- /test/jsonchecker/fail1.json: -------------------------------------------------------------------------------- 1 | "A JSON payload should be an object or array, not a string." -------------------------------------------------------------------------------- /test/jsonchecker/fail10.json: -------------------------------------------------------------------------------- 1 | {"Extra value after close": true} "misplaced quoted value" -------------------------------------------------------------------------------- /test/jsonchecker/fail11.json: -------------------------------------------------------------------------------- 1 | {"Illegal expression": 1 + 2} -------------------------------------------------------------------------------- /test/jsonchecker/fail12.json: -------------------------------------------------------------------------------- 1 | {"Illegal invocation": alert()} -------------------------------------------------------------------------------- /test/jsonchecker/fail13.json: -------------------------------------------------------------------------------- 1 | {"Numbers cannot have leading zeroes": 013} -------------------------------------------------------------------------------- /test/jsonchecker/fail14.json: -------------------------------------------------------------------------------- 1 | {"Numbers cannot be hex": 0x14} -------------------------------------------------------------------------------- /test/jsonchecker/fail15.json: -------------------------------------------------------------------------------- 1 | ["Illegal backslash escape: \x15"] -------------------------------------------------------------------------------- /test/jsonchecker/fail16.json: -------------------------------------------------------------------------------- 1 | [\naked] -------------------------------------------------------------------------------- /test/jsonchecker/fail17.json: -------------------------------------------------------------------------------- 1 | ["Illegal backslash escape: \017"] -------------------------------------------------------------------------------- /test/jsonchecker/fail18.json: -------------------------------------------------------------------------------- 1 | [[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]] -------------------------------------------------------------------------------- /test/jsonchecker/fail19.json: -------------------------------------------------------------------------------- 1 | {"Missing colon" null} -------------------------------------------------------------------------------- /test/jsonchecker/fail2.json: -------------------------------------------------------------------------------- 1 | ["Unclosed array" -------------------------------------------------------------------------------- /test/jsonchecker/fail20.json: -------------------------------------------------------------------------------- 1 | {"Double colon":: null} -------------------------------------------------------------------------------- /test/jsonchecker/fail21.json: -------------------------------------------------------------------------------- 1 | {"Comma instead of colon", null} -------------------------------------------------------------------------------- /test/jsonchecker/fail22.json: -------------------------------------------------------------------------------- 1 | ["Colon instead of comma": false] -------------------------------------------------------------------------------- /test/jsonchecker/fail23.json: -------------------------------------------------------------------------------- 1 | ["Bad value", truth] -------------------------------------------------------------------------------- /test/jsonchecker/fail24.json: -------------------------------------------------------------------------------- 1 | ['single quote'] -------------------------------------------------------------------------------- /test/jsonchecker/fail25.json: -------------------------------------------------------------------------------- 1 | [" tab character in string "] -------------------------------------------------------------------------------- /test/jsonchecker/fail26.json: -------------------------------------------------------------------------------- 1 | ["tab\ character\ in\ string\ "] -------------------------------------------------------------------------------- /test/jsonchecker/fail27.json: -------------------------------------------------------------------------------- 1 | ["line 2 | break"] -------------------------------------------------------------------------------- /test/jsonchecker/fail28.json: -------------------------------------------------------------------------------- 1 | ["line\ 2 | break"] -------------------------------------------------------------------------------- /test/jsonchecker/fail29.json: -------------------------------------------------------------------------------- 1 | [0e] -------------------------------------------------------------------------------- /test/jsonchecker/fail3.json: -------------------------------------------------------------------------------- 1 | {unquoted_key: "keys must be quoted"} -------------------------------------------------------------------------------- /test/jsonchecker/fail30.json: -------------------------------------------------------------------------------- 1 | [0e+] -------------------------------------------------------------------------------- /test/jsonchecker/fail31.json: -------------------------------------------------------------------------------- 1 | [0e+-1] -------------------------------------------------------------------------------- /test/jsonchecker/fail32.json: -------------------------------------------------------------------------------- 1 | {"Comma instead if closing brace": true, -------------------------------------------------------------------------------- /test/jsonchecker/fail33.json: -------------------------------------------------------------------------------- 1 | ["mismatch"} -------------------------------------------------------------------------------- /test/jsonchecker/fail4.json: -------------------------------------------------------------------------------- 1 | ["extra comma",] -------------------------------------------------------------------------------- /test/jsonchecker/fail5.json: -------------------------------------------------------------------------------- 1 | ["double extra comma",,] -------------------------------------------------------------------------------- /test/jsonchecker/fail6.json: -------------------------------------------------------------------------------- 1 | [ , "<-- missing value"] -------------------------------------------------------------------------------- /test/jsonchecker/fail7.json: -------------------------------------------------------------------------------- 1 | ["Comma after the close"], -------------------------------------------------------------------------------- /test/jsonchecker/fail8.json: -------------------------------------------------------------------------------- 1 | ["Extra close"]] -------------------------------------------------------------------------------- /test/jsonchecker/fail9.json: -------------------------------------------------------------------------------- 1 | {"Extra comma": true,} -------------------------------------------------------------------------------- /test/jsonchecker/pass1.json: -------------------------------------------------------------------------------- 1 | [ 2 | "JSON Test Pattern pass1", 3 | {"object with 1 member":["array with 1 element"]}, 4 | {}, 5 | [], 6 | -42, 7 | true, 8 | false, 9 | null, 10 | { 11 | "integer": 1234567890, 12 | "real": -9876.543210, 13 | "e": 0.123456789e-12, 14 | "E": 1.234567890E+34, 15 | "": 23456789012E66, 16 | "zero": 0, 17 | "one": 1, 18 | "space": " ", 19 | "quote": "\"", 20 | "backslash": "\\", 21 | "controls": "\b\f\n\r\t", 22 | "slash": "/ & \/", 23 | "alpha": "abcdefghijklmnopqrstuvwyz", 24 | "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", 25 | "digit": "0123456789", 26 | "0123456789": "digit", 27 | "special": "`1~!@#$%^&*()_+-={':[,]}|;.?", 28 | "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", 29 | "true": true, 30 | "false": false, 31 | "null": null, 32 | "array":[ ], 33 | "object":{ }, 34 | "address": "50 St. James Street", 35 | "url": "http://www.JSON.org/", 36 | "comment": "// /* */": " ", 38 | " s p a c e d " :[1,2 , 3 39 | 40 | , 41 | 42 | 4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7], 43 | "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", 44 | "quotes": "" \u0022 %22 0x22 034 "", 45 | "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" 46 | : "A key can be any string" 47 | }, 48 | 0.5 ,98.6 49 | , 50 | 99.44 51 | , 52 | 53 | 1066, 54 | 1e1, 55 | 0.1e1, 56 | 1e-1, 57 | 1e00,2e+00,2e-00 58 | ,"rosebud"] -------------------------------------------------------------------------------- /test/jsonchecker/pass2.json: -------------------------------------------------------------------------------- 1 | [[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]] -------------------------------------------------------------------------------- /test/jsonchecker/pass3.json: -------------------------------------------------------------------------------- 1 | { 2 | "JSON Test Pattern pass3": { 3 | "The outermost value": "must be an object or array.", 4 | "In this test": "It is an object." 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/jsonchecker/readme.txt: -------------------------------------------------------------------------------- 1 | Test suite from http://json.org/JSON_checker/. 2 | 3 | If the JSON_checker is working correctly, it must accept all of the pass*.json files and reject all of the fail*.json files. 4 | -------------------------------------------------------------------------------- /test/pyjsontestrunner.py: -------------------------------------------------------------------------------- 1 | # Simple implementation of a json test runner to run the test against json-py. 2 | 3 | import sys 4 | import os.path 5 | import json 6 | import types 7 | 8 | if len(sys.argv) != 2: 9 | print "Usage: %s input-json-file", sys.argv[0] 10 | sys.exit(3) 11 | 12 | input_path = sys.argv[1] 13 | base_path = os.path.splitext(input_path)[0] 14 | actual_path = base_path + '.actual' 15 | rewrite_path = base_path + '.rewrite' 16 | rewrite_actual_path = base_path + '.actual-rewrite' 17 | 18 | def valueTreeToString( fout, value, path = '.' ): 19 | ty = type(value) 20 | if ty is types.DictType: 21 | fout.write( '%s={}\n' % path ) 22 | suffix = path[-1] != '.' and '.' or '' 23 | names = value.keys() 24 | names.sort() 25 | for name in names: 26 | valueTreeToString( fout, value[name], path + suffix + name ) 27 | elif ty is types.ListType: 28 | fout.write( '%s=[]\n' % path ) 29 | for index, childValue in zip( xrange(0,len(value)), value ): 30 | valueTreeToString( fout, childValue, path + '[%d]' % index ) 31 | elif ty is types.StringType: 32 | fout.write( '%s="%s"\n' % (path,value) ) 33 | elif ty is types.IntType: 34 | fout.write( '%s=%d\n' % (path,value) ) 35 | elif ty is types.FloatType: 36 | fout.write( '%s=%.16g\n' % (path,value) ) 37 | elif value is True: 38 | fout.write( '%s=true\n' % path ) 39 | elif value is False: 40 | fout.write( '%s=false\n' % path ) 41 | elif value is None: 42 | fout.write( '%s=null\n' % path ) 43 | else: 44 | assert False and "Unexpected value type" 45 | 46 | def parseAndSaveValueTree( input, actual_path ): 47 | root = json.loads( input ) 48 | fout = file( actual_path, 'wt' ) 49 | valueTreeToString( fout, root ) 50 | fout.close() 51 | return root 52 | 53 | def rewriteValueTree( value, rewrite_path ): 54 | rewrite = json.dumps( value ) 55 | #rewrite = rewrite[1:-1] # Somehow the string is quoted ! jsonpy bug ? 56 | file( rewrite_path, 'wt').write( rewrite + '\n' ) 57 | return rewrite 58 | 59 | input = file( input_path, 'rt' ).read() 60 | root = parseAndSaveValueTree( input, actual_path ) 61 | rewrite = rewriteValueTree( json.write( root ), rewrite_path ) 62 | rewrite_root = parseAndSaveValueTree( rewrite, rewrite_actual_path ) 63 | 64 | sys.exit( 0 ) 65 | -------------------------------------------------------------------------------- /test/runjsontests.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import os.path 4 | from glob import glob 5 | import optparse 6 | 7 | VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef-value-errors=yes ' 8 | 9 | def compareOutputs( expected, actual, message ): 10 | expected = expected.strip().replace('\r','').split('\n') 11 | actual = actual.strip().replace('\r','').split('\n') 12 | diff_line = 0 13 | max_line_to_compare = min( len(expected), len(actual) ) 14 | for index in xrange(0,max_line_to_compare): 15 | if expected[index].strip() != actual[index].strip(): 16 | diff_line = index + 1 17 | break 18 | if diff_line == 0 and len(expected) != len(actual): 19 | diff_line = max_line_to_compare+1 20 | if diff_line == 0: 21 | return None 22 | def safeGetLine( lines, index ): 23 | index += -1 24 | if index >= len(lines): 25 | return '' 26 | return lines[index].strip() 27 | return """ Difference in %s at line %d: 28 | Expected: '%s' 29 | Actual: '%s' 30 | """ % (message, diff_line, 31 | safeGetLine(expected,diff_line), 32 | safeGetLine(actual,diff_line) ) 33 | 34 | def safeReadFile( path ): 35 | try: 36 | return file( path, 'rt' ).read() 37 | except IOError, e: 38 | return '' % (path,e) 39 | 40 | def runAllTests( jsontest_executable_path, input_dir = None, 41 | use_valgrind=False, with_json_checker=False ): 42 | if not input_dir: 43 | input_dir = os.path.join( os.getcwd(), 'data' ) 44 | tests = glob( os.path.join( input_dir, '*.json' ) ) 45 | if with_json_checker: 46 | test_jsonchecker = glob( os.path.join( input_dir, '../jsonchecker', '*.json' ) ) 47 | else: 48 | test_jsonchecker = [] 49 | failed_tests = [] 50 | valgrind_path = use_valgrind and VALGRIND_CMD or '' 51 | for input_path in tests + test_jsonchecker: 52 | is_json_checker_test = input_path in test_jsonchecker 53 | print 'TESTING:', input_path, 54 | options = is_json_checker_test and '--json-checker' or '' 55 | pipe = os.popen( "%s%s %s %s" % ( 56 | valgrind_path, jsontest_executable_path, options, 57 | input_path) ) 58 | process_output = pipe.read() 59 | status = pipe.close() 60 | if is_json_checker_test: 61 | expect_failure = os.path.basename( input_path ).startswith( 'fail' ) 62 | if expect_failure: 63 | if status is None: 64 | print 'FAILED' 65 | failed_tests.append( (input_path, 'Parsing should have failed:\n%s' % 66 | safeReadFile(input_path)) ) 67 | else: 68 | print 'OK' 69 | else: 70 | if status is not None: 71 | print 'FAILED' 72 | failed_tests.append( (input_path, 'Parsing failed:\n' + process_output) ) 73 | else: 74 | print 'OK' 75 | else: 76 | base_path = os.path.splitext(input_path)[0] 77 | actual_output = safeReadFile( base_path + '.actual' ) 78 | actual_rewrite_output = safeReadFile( base_path + '.actual-rewrite' ) 79 | file(base_path + '.process-output','wt').write( process_output ) 80 | if status: 81 | print 'parsing failed' 82 | failed_tests.append( (input_path, 'Parsing failed:\n' + process_output) ) 83 | else: 84 | expected_output_path = os.path.splitext(input_path)[0] + '.expected' 85 | expected_output = file( expected_output_path, 'rt' ).read() 86 | detail = ( compareOutputs( expected_output, actual_output, 'input' ) 87 | or compareOutputs( expected_output, actual_rewrite_output, 'rewrite' ) ) 88 | if detail: 89 | print 'FAILED' 90 | failed_tests.append( (input_path, detail) ) 91 | else: 92 | print 'OK' 93 | 94 | if failed_tests: 95 | print 96 | print 'Failure details:' 97 | for failed_test in failed_tests: 98 | print '* Test', failed_test[0] 99 | print failed_test[1] 100 | print 101 | print 'Test results: %d passed, %d failed.' % (len(tests)-len(failed_tests), 102 | len(failed_tests) ) 103 | return 1 104 | else: 105 | print 'All %d tests passed.' % len(tests) 106 | return 0 107 | 108 | def main(): 109 | from optparse import OptionParser 110 | parser = OptionParser( usage="%prog [options] [test case directory]" ) 111 | parser.add_option("--valgrind", 112 | action="store_true", dest="valgrind", default=False, 113 | help="run all the tests using valgrind to detect memory leaks") 114 | parser.add_option("-c", "--with-json-checker", 115 | action="store_true", dest="with_json_checker", default=False, 116 | help="run all the tests from the official JSONChecker test suite of json.org") 117 | parser.enable_interspersed_args() 118 | options, args = parser.parse_args() 119 | 120 | if len(args) < 1 or len(args) > 2: 121 | parser.error( 'Must provides at least path to jsontestrunner executable.' ) 122 | sys.exit( 1 ) 123 | 124 | jsontest_executable_path = os.path.normpath( os.path.abspath( args[0] ) ) 125 | if len(args) > 1: 126 | input_path = os.path.normpath( os.path.abspath( args[1] ) ) 127 | else: 128 | input_path = None 129 | status = runAllTests( jsontest_executable_path, input_path, 130 | use_valgrind=options.valgrind, with_json_checker=options.with_json_checker ) 131 | sys.exit( status ) 132 | 133 | if __name__ == '__main__': 134 | main() 135 | -------------------------------------------------------------------------------- /test/runjsontests.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/runjsontests.pyc -------------------------------------------------------------------------------- /test/rununittests.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import os.path 4 | import subprocess 5 | from glob import glob 6 | import optparse 7 | 8 | VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef-value-errors=yes' 9 | 10 | class TestProxy(object): 11 | def __init__( self, test_exe_path, use_valgrind=False ): 12 | self.test_exe_path = os.path.normpath( os.path.abspath( test_exe_path ) ) 13 | self.use_valgrind = use_valgrind 14 | 15 | def run( self, options ): 16 | if self.use_valgrind: 17 | cmd = VALGRIND_CMD.split() 18 | else: 19 | cmd = [] 20 | cmd.extend( [self.test_exe_path, '--test-auto'] + options ) 21 | process = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) 22 | stdout = process.communicate()[0] 23 | if process.returncode: 24 | return False, stdout 25 | return True, stdout 26 | 27 | def runAllTests( exe_path, use_valgrind=False ): 28 | test_proxy = TestProxy( exe_path, use_valgrind=use_valgrind ) 29 | status, test_names = test_proxy.run( ['--list-tests'] ) 30 | if not status: 31 | print >> sys.stderr, "Failed to obtain unit tests list:\n" + test_names 32 | return 1 33 | test_names = [name.strip() for name in test_names.strip().split('\n')] 34 | failures = [] 35 | for name in test_names: 36 | print 'TESTING %s:' % name, 37 | succeed, result = test_proxy.run( ['--test', name] ) 38 | if succeed: 39 | print 'OK' 40 | else: 41 | failures.append( (name, result) ) 42 | print 'FAILED' 43 | failed_count = len(failures) 44 | pass_count = len(test_names) - failed_count 45 | if failed_count: 46 | print 47 | for name, result in failures: 48 | print result 49 | print '%d/%d tests passed (%d failure(s))' % ( 50 | pass_count, len(test_names), failed_count) 51 | return 1 52 | else: 53 | print 'All %d tests passed' % len(test_names) 54 | return 0 55 | 56 | def main(): 57 | from optparse import OptionParser 58 | parser = OptionParser( usage="%prog [options] " ) 59 | parser.add_option("--valgrind", 60 | action="store_true", dest="valgrind", default=False, 61 | help="run all the tests using valgrind to detect memory leaks") 62 | parser.enable_interspersed_args() 63 | options, args = parser.parse_args() 64 | 65 | if len(args) != 1: 66 | parser.error( 'Must provides at least path to test_lib_json executable.' ) 67 | sys.exit( 1 ) 68 | 69 | exit_code = runAllTests( args[0], use_valgrind=options.valgrind ) 70 | sys.exit( exit_code ) 71 | 72 | if __name__ == '__main__': 73 | main() 74 | -------------------------------------------------------------------------------- /test/rununittests.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henshao/jsoncpp/4eb2d915defe596f656a5ee3efafd44a8bd5b472/test/rununittests.pyc -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- 1 | 0.5.0 --------------------------------------------------------------------------------