Jsoncpp
DownloadSource code, Set the environment as follows. This environment must be used with the application that calls jsoncpp.ProgramThe environment is the same. The debug and relese are different and need to be modified. For details about release,ArticleNote:
TestCodeCopy the header file and library file of JSON. to the current project directory.
// Demo2.cpp: defines the entry point of the console application. // # Include "stdafx. H "# pragma comment (Lib," json_vc71_libmtd.lib ") # include" JSON/JSON. H "int _ tmain (INT argc, _ tchar * argv []) {JSON: Value root; JSON: Value person; person ["name"] = "Hello World"; person ["Age"] = 12; root. append (person); person ["name"] = "JSON"; person ["Age"] = 13; root. append (person); STD: string name; int age; int size = root. size (); For (INT I = 0; I <size; I ++) {name = root [I] ["name"]. asstring (); age = root [I] [" GE "]. asint (); STD: cout <name <"" <age <STD: Endl;} JSON: fastwriter FW; STD: cout <FW. write (Root) <STD: Endl; STD: String MSG = fw. write (Root); // deserialization JSON: reader freader; JSON: Value rootr; freader. parse (MSG, rootr); For (INT I = 0; I <size; I ++) {name = root [I] ["name"]. asstring (); age = root [I] ["Age"]. asint (); STD: cout <name <"" <age <STD: Endl;} // obtain the key, only root [0], only elements in root [1] have key JSON: Value: Members (roo T [1]. getmembernames (); For (JSON: Value: Members: iterator it = members. Begin (); it! = Members. end (); ++ it) {const STD: string & Key = * it; const STD: String valuetemp = root [I] [Key]. asstring (); STD: cout <key <STD: Endl;} // Ctrl + F5 compile and run return 0 ;}
In addition, if the following error occurs in the release version
1> generating code
1> E: \ source \ Vc \ sources \ JSON \ jsoncpp-src-0.6.0-rc2 \ SRC \ lib_json \ json_value.cpp: Fatal error c1083: Unable to open the file generated by the compiler: ".. /.. /build/vs71/release/lib_json \ json_value.asm ": no such file or directory
1> link: Fatal error lnk1257: code generation failed
See http://bbs.csdn.net/topics/380043500
Modify the property of the project that generates the static library file: Path: menu --- project -- Property --- configuration property --- C/C ++ --- output file --- assembler output: no list