# cJSON
Ultralightweight JSON parser in ANSI C.
## Table of contents
* [License](#license)
* [Usage](#usage)
* [Welcome to cJSON](#welcome-to-cjson)
* [Building](#building)
* [Copying the source](#copying-the-source)
* [CMake](#cmake)
* [Makefile](#makefile)
* [Vcpkg](#Vcpkg)
* [Including cJSON](#including-cjson)
* [Data Structure](#data-structure)
* [Working with the data structure](#working-with-the-data-structure)
* [Basic types](#basic-types)
* [Arrays](#arrays)
* [Objects](#objects)
* [Parsing JSON](#parsing-json)
* [Printing JSON](#printing-json)
* [Example](#example)
* [Printing](#printing)
* [Parsing](#parsing)
* [Caveats](#caveats)
* [Zero Character](#zero-character)
* [Character Encoding](#character-encoding)
* [C Standard](#c-standard)
* [Floating Point Numbers](#floating-point-numbers)
* [Deep Nesting Of Arrays And Objects](#deep-nesting-of-arrays-and-objects)
* [Thread Safety](#thread-safety)
* [Case Sensitivity](#case-sensitivity)
* [Duplicate Object Members](#duplicate-object-members)
* [Enjoy cJSON!](#enjoy-cjson)
## License
MIT License
> Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
## Usage
### Welcome to cJSON.
cJSON aims to be the dumbest possible parser that you can get your job done with.
It's a single file of C, and a single header file.
JSON is described best here: http://www.json.org/
It's like XML, but fat-free. You use it to move data around, store things, or just
generally represent your program's state.
As a library, cJSON exists to take away as much legwork as it can, but not get in your way.
As a point of pragmatism (i.e. ignoring the truth), I'm going to say that you can use it
in one of two modes: Auto and Manual. Let's have a quick run-through.
I lifted some JSON from this page: http://www.json.org/fatfree.html
That page inspired me to write cJSON, which is a parser that tries to share the same
philosophy as JSON itself. Simple, dumb, out of the way.
### Building
There are several ways to incorporate cJSON into your project.
#### copying the source
Because the entire library is only one C file and one header file, you can just copy `cJSON.h` and `cJSON.c` to your projects source and start using it.
cJSON is written in ANSI C (C89) in order to support as many platforms and compilers as possible.
#### CMake
With CMake, cJSON supports a full blown build system. This way you get the most features. CMake with an equal or higher version than 2.8.5 is supported. With CMake it is recommended to do an out of tree build, meaning the compiled files are put in a directory separate from the source files. So in order to build cJSON with CMake on a Unix platform, make a `build` directory and run CMake inside it.
```
mkdir build
cd build
cmake ..
```
This will create a Makefile and a bunch of other files. You can then compile it:
```
make
```
And install it with `make install` if you want. By default it installs the headers `/usr/local/include/cjson` and the libraries to `/usr/local/lib`. It also installs files for pkg-config to make it easier to detect and use an existing installation of CMake. And it installs CMake config files, that can be used by other CMake based projects to discover the library.
You can change the build process with a list of different options that you can pass to CMake. Turn them on with `On` and off with `Off`:
* `-DENABLE_CJSON_TEST=On`: Enable building the tests. (on by default)
* `-DENABLE_CJSON_UTILS=On`: Enable building cJSON_Utils. (off by default)
* `-DENABLE_TARGET_EXPORT=On`: Enable the export of CMake targets. Turn off if it makes problems. (on by default)
* `-DENABLE_CUSTOM_COMPILER_FLAGS=On`: Enable custom compiler flags (currently for Clang, GCC and MSVC). Turn off if it makes problems. (on by default)
* `-DENABLE_VALGRIND=On`: Run tests with [valgrind](http://valgrind.org). (off by default)
* `-DENABLE_SANITIZERS=On`: Compile cJSON with [AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer) and [UndefinedBehaviorSanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html) enabled (if possible). (off by default)
* `-DENABLE_SAFE_STACK`: Enable the [SafeStack](https://clang.llvm.org/docs/SafeStack.html) instrumentation pass. Currently only works with the Clang compiler. (off by default)
* `-DBUILD_SHARED_LIBS=On`: Build the shared libraries. (on by default)
* `-DBUILD_SHARED_AND_STATIC_LIBS=On`: Build both shared and static libraries. (off by default)
* `-DCMAKE_INSTALL_PREFIX=/usr`: Set a prefix for the installation.
* `-DENABLE_LOCALES=On`: Enable the usage of localeconv method. ( on by default )
* `-DCJSON_OVERRIDE_BUILD_SHARED_LIBS=On`: Enable overriding the value of `BUILD_SHARED_LIBS` with `-DCJSON_BUILD_SHARED_LIBS`.
* `-DENABLE_CJSON_VERSION_SO`: Enable cJSON so version. ( on by default )
If you are packaging cJSON for a distribution of Linux, you would probably take these steps for example:
```
mkdir build
cd build
cmake .. -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off -DCMAKE_INSTALL_PREFIX=/usr
make
make DESTDIR=$pkgdir install
```
On Windows CMake is usually used to create a Visual Studio solution file by running it inside the Developer Command Prompt for Visual Studio, for exact steps follow the official documentation from CMake and Microsoft and use the online search engine of your choice. The descriptions of the the options above still generally apply, although not all of them work on Windows.
#### Makefile
**NOTE:** This Method is deprecated. Use CMake if at all possible. Makefile support is limited to fixing bugs.
If you don't have CMake available, but still have GNU make. You can use the makefile to build cJSON:
Run this command in the directory with the source code and it will automatically compile static and shared libraries and a little test program (not the full test suite).
```
make all
```
If you want, you can install the compiled library to your system using `make install`. By default it will install the headers in `/usr/local/include/cjson` and the libraries in `/usr/local/lib`. But you can change this behavior by setting the `PREFIX` and `DESTDIR` variables: `make PREFIX=/usr DESTDIR=temp install`. And uninstall them with: `make PREFIX=/usr DESTDIR=temp uninstall`.
#### Vcpkg
You can download and install cJSON using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
```
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install cjson
```
The cJSON port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
### Including cJSON
If you installed it via CMake or the Makefile, you can include cJSON like this:
```c
#i
没有合适的资源?快使用搜索试试~ 我知道了~
OTA远程升级资源文件
3 下载量 51 浏览量
2023-08-22
13:47:37
上传
评论
收藏 683.99MB GZ 举报
温馨提示
共908个文件
c:209个
h:65个
so:56个
OTA远程升级资源文件
资源推荐
资源详情
资源评论
收起资源包目录
OTA远程升级资源文件 (908个子文件)
libgmssl.so.3.0 944KB
libgmssl.so.3.0 944KB
libgmssl.so.3.0 944KB
libcrypto.so.1.1 2MB
libcrypto.so.1.1 2MB
libcrypto.so.1.1 2MB
libcrypto.so.1.1 2MB
libcrypto.so.1.1 2MB
libnanomsg.so.6.0.1 376KB
libnanomsg.so.6.0.1 376KB
libnanomsg.so.6.0.1 376KB
libpaho-mqtt3as.so.1 270KB
libpaho-mqtt3as.so.1 270KB
libpaho-mqtt3as.so.1 270KB
libpaho-mqtt3as.so.1 270KB
libpaho-mqtt3as.so.1 270KB
libpaho-mqtt3as.so.1 270KB
libpaho-mqtt3as.so.1 270KB
libpaho-mqtt3as.so.1 270KB
libz.so.1 70KB
libz.so.1 70KB
libz.so.1 70KB
libz.so.1 70KB
libz.so.1 70KB
libz.so.1 70KB
libz.so.1 70KB
libz.so.1 70KB
v1.1 90B
libz.so.1.2.11 70KB
libz.so.1.2.11 70KB
libz.so.1.2.11 70KB
libz.so.1.2.11 70KB
libz.so.1.2.11 70KB
libz.so.1.2.11 70KB
libz.so.1.2.11 70KB
libz.so.1.2.11 70KB
libpaho-mqtt3as.so.1.3.12 270KB
libpaho-mqtt3as.so.1.3.12 270KB
libpaho-mqtt3as.so.1.3.12 270KB
libpaho-mqtt3as.so.1.3.12 270KB
libpaho-mqtt3as.so.1.3.12 270KB
libpaho-mqtt3as.so.1.3.12 270KB
libpaho-mqtt3as.so.1.3.12 270KB
libpaho-mqtt3as.so.1.3.12 270KB
v1.2 16.49MB
libgcrypt.so.20 619KB
libgcrypt.so.20 619KB
libgcrypt.so.20 619KB
libgcrypt.so.20 619KB
libgcrypt.so.20 619KB
libcrypto.so.3 4.36MB
libcrypto.so.3 4.36MB
libcrypto.so.3 4.36MB
libcrypto.so.3 4.36MB
libgmssl.so.3 944KB
libgmssl.so.3 944KB
libgmssl.so.3 944KB
libssl.so.3 761KB
libssl.so.3 761KB
libssl.so.3 761KB
libssl.so.3 761KB
libgcrypt.so.20.2.4 619KB
libgcrypt.so.20.2.4 619KB
libgcrypt.so.20.2.4 619KB
libgcrypt.so.20.2.4 619KB
libgcrypt.so.20.2.4 619KB
libnanomsg.so.6 376KB
libnanomsg.so.6 376KB
libnanomsg.so.6 376KB
v1.A 16.49MB
v1.A 16.49MB
libcrypto.a 8.54MB
libssl.a 1.21MB
libssl.a 1.21MB
v1.A 140B
AEBS 7.62MB
AEBS 7.29MB
AEBS 7.29MB
AEBS-1 7.29MB
async_c 14KB
minIni.zip.bak 38KB
makefile.bak 354B
history.ini.bak 303B
JCST-C06-23RD06-R010.bin 87KB
JCST-C05-23RD06-R009.bin 87KB
JCST-C05-23RD06-R006.bin 85KB
JCST-ZK07-22009-R001.bin 82KB
JCST-ZK07-22009-R001.bin 82KB
JCST-A06-23RD06-R005.bin 72KB
ping.bin 5B
ping.bin 5B
JCST-ZK07-22009-R001.bin-1 82KB
ping.bin-1 17B
test3.bu 603B
log.c 124KB
log.c 124KB
log.c 124KB
testunity.c 121KB
log.c 119KB
log.c 119KB
共 908 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
讳疾忌医丶
- 粉丝: 1w+
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 问题1 只考虑使用A类无人机,请给出公交与无人机协同配送方案,使总费用最小;要求给出具体的飞行路径及时刻表无人机.xlsx
- NCSU PDK 45nm
- E语言 CompleteUI-窗体控件美化支持库1.0版(静态版CompleteUI.fne)
- PyQt5实现PDF预览
- VMware-ESXI7.0.2镜像
- YOLOv8绘制map曲线图,采用matlab实现
- 毕业设计基于mysql+php实现的外卖点餐系统源码+答辩PPT+项目说明文档.zip
- OCPP-2.0.1 欧洲V2G开放充电协议
- 无人机自主导航-基于强化学习实现的无人机自主导航-附项目源码-优质项目实战.zip
- 2024金地杯本科组赛题.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功