Use jsoncpp (JSON) in VC)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.