Linux installation Json-c

Source: Internet
Author: User

0. Introduction to JSON

JSON (JavaScript Object Notation) is a lightweight data interchange format. Easy for people to read and write. It is also easy for machine parsing and generation.

JSON takes a completely language-independent text format, but also uses a similar idiom to the C language family (c, C + +, C #, Java, JavaScript, Perl, Python, etc.). These features make JSON an ideal data exchange language.

Compared with XML, the advantage of JSON is that the format is concise and short, especially when dealing with a large number of complex data, this advantage is very prominent. From the support of each browser, JSON solves the problem caused by different browsers parsing the XML DOM in different ways.

★jason's Learning materials

http://www.json.org/(English) http://www.json.org/json-zh.html (Chinese)

http://www.w3school.com.cn/json/

http://www.ibm.com/developerworks/cn/web/wa-lo-json/

★jason-c's introduction

The JSON library is diverse, but json-c is widely used because of its compatibility and support for UTF-8.

As far as JSON is concerned, because the structure is relatively simple, it is possible to use a library.

However, JSON-C provides some functions beyond the JSON range, and actually completes the functions of data serialization and deserialization, data storage and retrieval, data object and so on. It is of very useful value.

Https://github.com/json-c/json-c/wiki

http://zengriguang.blog.163.com/blog/static/17076248720121080187635/

1. Compiling json-c
//Get Source code [root]# Yum Install git [root]# git clone https://github.com/json-c/json-c.git//compile install [root]# cd json-c[root]# . /autogen.sh[root]# ./configure[root]#make] [root]# make Install

2. Using Json-c

If you don't have pkgconfig in Linux

//Installation Pkgconfig [root] # Yum Install Pkgconfig

Compile using json-c header file, link Json-c library need to add the following dependency in makefile

CFLAGS + = $ (Shell pkg-config--cflags json-c) ldflags += $ (Shell pkg-config--libs json-c)
or a little simpler.
GCC ' pkg-config--cflags--libs json-c ' - o target xxx.c

3. Example

4, Json-c's readme.md file
' Json-c '========Building on Unix with ' git ', ' gcc ' and ' autotools '--------------------------------------------------Home page for json-c: https:// Github.com/json-c/json-c/wikicaution:do **not** use sources from svn.metaparadigm.com,they is old. Prerequisites:-' gcc ', ' Clang ',or another C compiler-' libtool ' If you ' re not using a release tarball,You'll also need:-' autoconf ' (' autoreconf ')-' automake ' make sure ' Install Libtool ' witha complete ' ' 7 >, including ' libtoolize '. ' Json-c ' GitHub repo:https://github.com/json-c/json-c ' bash$ git clone https://github.com/json-c/json-c.git$ CD json-c$ sh autogen.sh"followed by" Bash$./configure$ make$ make install"to build and run the test prog Rams: "Bash $ makecheck" ' Linking to ' libjson-c '----------------------If your system have ' pkgconfig ',Then you can just add this to your ' makefile ': "MakeCFLAGS + = $ (Shell pkg-config--cflags json-c) ldflags + = $ (Shell pkg-config--libs json-c)' without ' pkgconfig ',You would does something like this: "Make json_c_dir =/path/to/json_c/installcflags + =-i$ (json_c_dir)/include/json-cldflags+= -l$ (json_c_dir)/lib-ljson-c"

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.