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的更多相关文章
- JsonDataObjects基本演示
下载地址https://github.com/ahausladen/JsonDataObjects 执行程序截图 Json数据 { "name": "张三", ...
- JsonDataObjects 简单实用
下载地址https://github.com/ahausladen/JsonDataObjects Simple example var Obj: TJsonObject; begin Obj := ...
- JsonDataObjects序列和还原
JsonDataObjects序列和还原 JsonDataObjects号称DELPHI最快的JSON库,且支持跨平台. // cxg 2017-9-12// Use JsonDataObjects( ...
- delphi-json组件,速度非常快,要比superobject快好几倍
delphi-json组件,速度非常快,要比superobject快好几倍https://github.com/ahausladen/JsonDataObjectshttp://bbs.2ccc.co ...
- Delphi语言最好的JSON代码库 mORMot学习笔记1
mORMot没有控件安装,直接添加到lib路径,工程中直接添加syncommons,syndb等到uses里 --------------------------------------------- ...
- Delphi json解析相关
身为一个资深的Delphi 开发者, 最近在做一个小工具的时候,开始捡起来pascal语言. 主要是开发一个内部用的小工具, 主要功能: 1.解析json格式 2.格式化json文件 3.校验json ...
- delphi c++builder JSON 生成与解析 例子
json,System.JSON,REST.JSON JSON有两种数据结构,对象和数组. 对象在js中表示为“{}”括起来的内容,数据结构为 {key:value,key:value,...} 数组 ...
- DELPHI的一些开源项目GIT地址
DELPHI的一些开源项目GIT地址 Delphi-Cross-Sockethttps://github.com/winddriver/Delphi-Cross-Socket 跨平台的SOCKET库 ...
- Delphi语言最好的JSON代码库 mORMot学习笔记1(无数评论)
mORMot没有控件安装,直接添加到lib路径,工程中直接添加syncommons,syndb等到uses里 --------------------------------------------- ...
随机推荐
- Maven3核心技术(笔记三)
第一节:Maven仓库概念 Maven 远程仓库配置文件:$M2_HOME/lib/maven-model-builder-3.3.3.jar 文件:org\apache\maven\model\po ...
- springMVC源码分析--HttpMessageConverter写write操作(三)
上一篇博客springMVC源码分析--HttpMessageConverter参数read操作中我们已经简单介绍了参数值转换的read操作,接下来我们介绍一下返回值的处理操作.同样返回值的操作操作也 ...
- SQL Server中删除表中重复数据
方法一:利用游标,但要注意主字段或标识列 declare @max integer,@id integer open cur_rows fetch cur_rows into @id,@max beg ...
- MySQL学习笔记:生成一个时间序列
今天遇到一个需求是生成以下表格的数据,一整天24小时,每秒一行数据. 寻找颇旧,找到另外两个实现的例子,暂且学习一翻.另一个见另外一篇. DAY) AS DATE FROM ( ) AS tmp, ( ...
- Linux 相关
一.WCHAN的含义 WCHAN 进程正在睡眠的内核函数名称:该函数的名称是从/root/system.map文件中获得的. 参考:解析ANDROID ps命令执行后各项参数的含义 二.查看线程 ps ...
- Elasticsearch 6.x 的分页查询数据
{ , "query": { "match" : { "person_name" : "张老师" }}, , ], &q ...
- MFC+WinPcap编写一个嗅探器之五(过滤模块)
这一节主要介绍如何获设置捕获过滤,这里的过滤是指在捕获前过滤 设置捕获过滤主要是在CFilterDlg中完成,也就是对应之前创建的设置过滤规则对话框,如图: 首先要根据用户的选择来生成一个合法的过滤规 ...
- USACO 6.4 Wisconsin Squares
Wisconsin Squares It's spring in Wisconsin and time to move the yearling calves to the yearling past ...
- 007 Ajax中的购物车
1.大纲设计 2.shopingCartItem.java package beans; public class shopingCartItem { private String bookname; ...
- synchoronized和lock区别
synchoronized是JVM的内置锁,而lock是Java代码实现的.lock是sync对的扩展,完全可以替代后者.lock可以重入,允许同一个线程连续多次获得同一把锁.其次,lock独有的功能 ...