jsondataobjects

GITHUB:

https://github.com/ahausladen/jsondataobjects.git

跨平台JSON库

Json Data Objects
=================

This Delphi unit contains a JSON parser that supports Delphi 2009-10Seattle and the platforms
Win32, Win64 and ARM Android (MacOS and iOS may work).

Clone with GIT
--------------
```
> git clone git@github.com:ahausladen/JsonDataObjects.git
```
or
```
> git clone https://github.com/ahausladen/JsonDataObjects.git
```

This will get you the Json Data Objects repository.

How to install
--------------
1. Clone the JsonDataObjects repository
2. Add the JsonDataObjects.pas unit to your project.

Features
--------
* Fast dual JSON parser for parsing UTF8 and UTF16 without conversion
* Automatic creation of arrays and objects
* Easy access mode with implicit operators
* Compact and formatted output modes
* Variants support
* Null can be auto-typecasted to a value type if JsonSerializationConfig.NullConvertsToValueTypes is set to True
* Progress callback support for loading large JSON strings
* Win32, Win64 and ARM Android support (MacOS and iOS may work)

Usage
-----
Simple example
```Delphi
var
Obj: TJsonObject;
begin
Obj := TJsonObject.Parse('{ "foo": "bar", "array": [ 10, 20 ] }') as TJsonObject;
try
ShowMessage(Obj['foo']);
ShowMessage(IntToStr(Obj['array'].Count));
ShowMessage(IntToStr(Obj['array'].Items[0]));
ShowMessage(IntToStr(Obj['array'].Items[1]));
finally
Obj.Free;
end;
end;
```

Filling and serializing JSON objects
```Delphi
var
Obj, ChildObj: TJsonObject;
begin
Obj := TJsonObject.Create;
try
// easy access
Obj['foo'] := 'bar';
// normal (and faster) access
Obj.S['bar'] := 'foo';
// automatic array creation, Obj is the owner of 'array'
Obj.A['array'].Add(10);
Obj.A['array'].Add(20);
// automatic object creation, 'array' is the owner of ChildObj
ChildObj := Obj.A['array'].AddObject;
ChildObj['value'] := 12.3;
// automatic array creation, ChildObj is the owner of 'subarray'
ChildObj.A['subarray'].Add(100);
ChildObj.A['subarray'].Add(200);

ShowMessage(Obj.ToJSON({Compact:=}False));
finally
Obj.Free;
end;
```
```JSON
{
"foo": "bar",
"bar": "foo",
"array": [
10,
20,
{
"value": 12.3,
"subarray": [
100,
200
]
}
]
}
```

Copying JSON objects with `Assign`
```Delphi
var
Obj, ClonedObj: TJsonObject;
begin
Obj := TJsonObject.ParseUtf8('{ "foo": [ "bar", {}, null, true, false, { "key": "value" } ] }') as TJsonObject;
try
ClonedObj := TJsonObject.Create;
try
// Make a copy of Obj
ClonedObj.Assign(Obj);
ShowMessage(ClonedObj.ToJSON(False));
finally
ClonedObj.Free;
end;
finally
Obj.Free;
end;
end;
```
```JSON
{
"foo": [
"bar",
{},
null,
true,
false,
{
"key": "value"
}
]
}
```

jsondataobjects的更多相关文章

  1. JsonDataObjects基本演示

    下载地址https://github.com/ahausladen/JsonDataObjects 执行程序截图 Json数据 { "name": "张三", ...

  2. JsonDataObjects 简单实用

    下载地址https://github.com/ahausladen/JsonDataObjects Simple example var Obj: TJsonObject; begin Obj := ...

  3. JsonDataObjects序列和还原

    JsonDataObjects序列和还原 JsonDataObjects号称DELPHI最快的JSON库,且支持跨平台. // cxg 2017-9-12// Use JsonDataObjects( ...

  4. delphi-json组件,速度非常快,要比superobject快好几倍

    delphi-json组件,速度非常快,要比superobject快好几倍https://github.com/ahausladen/JsonDataObjectshttp://bbs.2ccc.co ...

  5. Delphi语言最好的JSON代码库 mORMot学习笔记1

    mORMot没有控件安装,直接添加到lib路径,工程中直接添加syncommons,syndb等到uses里 --------------------------------------------- ...

  6. Delphi json解析相关

    身为一个资深的Delphi 开发者, 最近在做一个小工具的时候,开始捡起来pascal语言. 主要是开发一个内部用的小工具, 主要功能: 1.解析json格式 2.格式化json文件 3.校验json ...

  7. delphi c++builder JSON 生成与解析 例子

    json,System.JSON,REST.JSON JSON有两种数据结构,对象和数组. 对象在js中表示为“{}”括起来的内容,数据结构为 {key:value,key:value,...} 数组 ...

  8. DELPHI的一些开源项目GIT地址

    DELPHI的一些开源项目GIT地址 Delphi-Cross-Sockethttps://github.com/winddriver/Delphi-Cross-Socket 跨平台的SOCKET库 ...

  9. Delphi语言最好的JSON代码库 mORMot学习笔记1(无数评论)

    mORMot没有控件安装,直接添加到lib路径,工程中直接添加syncommons,syndb等到uses里 --------------------------------------------- ...

随机推荐

  1. A - Superset CodeForces - 97B(人生第一个分治法,感觉,像二分啊。。)

    /* 分治法,第一次做不是很懂,借鉴了神犇代码,但实操之后感觉像二分,,可能做得少了或者就是.... */ 题目大意: 一个集合里有若干点,要求你添加某些点后保证这个集合里的任意两点满足以下三个条件中 ...

  2. 监控cpu、内存 <shell>

    获取cpu.内存结果 pid=$1 #获取进程pid echo $pid interval=1 #设置采集间隔 while true do echo $(date +"%y-%m-%d %H ...

  3. sort change from to range

    SORT FIELDS=COPY OUTREC FINDREP=(IN=X'05',OUT=X'40', STARTPOS=107,ENDPOS=204)

  4. 【Memory】chrome调试面板

    本篇文章以chrome版本67.0.3396.99为例,介绍如何使用Chrome和DevTools查找影响页面性能的内存问题,包括内存泄漏.内存膨胀和频繁的垃圾回收. 一.参考链接 https://d ...

  5. ceph部署过程中的错误

    ceph版本-jewel 用ssd盘来journal ,格式分区权限问题 [ceph-node2][WARNIN] ceph_disk.main.FilesystemTypeError: Cannot ...

  6. python opencv3 视频文件的读写

    git: https://github.com/linyi0604/Computer-Vision # coding:utf8 import cv2 """ 读取视频文件 ...

  7. 机器学习之路: python 决策树分类DecisionTreeClassifier 预测泰坦尼克号乘客是否幸存

    使用python3 学习了决策树分类器的api 涉及到 特征的提取,数据类型保留,分类类型抽取出来新的类型 需要网上下载数据集,我把他们下载到了本地, 可以到我的git下载代码和数据集: https: ...

  8. php开启redis扩展

    1.安装redis git下载地址https://github.com/MSOpenTech/redis/releases 2.测试redis windows 运行(快捷键:windows键+R键), ...

  9. springboot配置多数据源mongodb

    参考大佬的文章 https://juejin.im/entry/5ab304dd51882555825241b3

  10. hdu 5316 Magician(2015多校第三场第1题)线段树单点更新+区间合并

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5316 题意:给你n个点,m个操作,每次操作有3个整数t,a,b,t表示操作类型,当t=1时讲a点的值改 ...