jsondataobjects
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相关推荐
- Delphi语言最好的JSON代码库 mORMot学习笔记1
mORMot没有控件安装,直接添加到lib路径, 工程中直接添加syncommons,syndb等到uses里 -------------------------------------------- ...
- 今天偶尔逛delphi的论坛,看到的json文章,收藏
在进行网络编程中需要JSON对象的构建与解析, 这个Delphi XE+自带: {$IF CompilerVersion>22}, System.JSon{$ELSE}, DBXJSON{$IF ...
最新文章
- 高并发 python socket send 异步_对于Python中socket.listen()与多线程结合的困惑?
- html制作动态坐标轴,HTML5 canvas制作动态随机星图
- 说说JSON和JSONP
- 分享个提高自己审美的网站
- 单调栈解木板倒水问题
- kendo实现grid的inline编辑
- CloseableHttpClient 在使用过程中遇到的问题
- 「镁客·请讲」ETC社区发起人邹来辉(Roy):我为什么要做ETC社区和狗狗币基金会?...
- 蓝牙版本avrcp怎么选_「科技犬」除了苹果AirPods,真无线蓝牙耳机到底怎么选?...
- 为什么计算机连不上无线网络,为什么电脑连不上wifi(wifi正常 电脑连不上网)
- 2017南开秋奥鹏作业计算机,南开17秋学期《DirectX程序设计》在线作业(资料)...
- 淘淘摘苹果Python版
- 「数字化转型」数字化转型的12个步骤
- python urllib模块
- linux--redis(redis在lnmp中做加速器2)
- 第三方支付平台的状态表
- 【汇编综合应用】大小写字母的转换、2号、9号和10号DOS系统功能调用、分支、循环程序结构、子程序、寄存器传递参数,宏定义、宏调用,观察宏展开。
- 华为手机助手安卓版_手机资料恢复助手app下载-手机资料恢复助手app安卓版下载v1.0...
- mysql建表语句 numeric_数据库建表语句
- CAT ----分布式实时监控系统
热门文章
- HDOJ 1285 确定比赛名次(拓扑排序)
- Windows安装.net Framework时安装不上,提示已处理证书链,但是在不受信任提供程序信任的根证书中终止
- JS 数组常用函数(数组合并、数组转字符串、顺序反转、范围选择、排序、插入数据、删除数据)
- JS 判断输入是否为数字
- QT5_数据类型转化
- 集群IPtables转发与防火墙
- WPF ComboBox下拉绑定Treeview 功能的实现
- Servlet实现文件上传
- 【C/C++】递归算法
- PHP通过OpenSSL生成证书、密钥并且加密解密数据,以及公钥,私钥和数字签名的理解...