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. test.c

    test.c #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include < ...

  2. 使用mockito模拟静态方法

    一.为什么要使用Mock工具 在做单元测试的时候,我们会发现我们要测试的方法会引用很多外部依赖的对象,比如:(发送邮件,网络通讯,远程服务, 文件系统等等). 而我们没法控制这些外部依赖的对象,为了解 ...

  3. LoadRunner对不同协议的选择

    LoadRunner对不同协议的选择 大家常用的是Loadrunner测试web(Http/Html),但其实协议多种多样.在B/S结构的网站多种业务的特点需要选择不同的协议,协议如何选择呢,寻找了相 ...

  4. tomcat中请求参数中文中乱码问题

    在server.xml中配置如下: <Connector connectionTimeout="20000" port="8080" protocol=& ...

  5. Dubbo的容错与负载均衡

    虽然前面在介绍dubbo中写过这块内容,但是不够充分,这里详细写一下,在以后研究中,还会继续补充程序原理. 一:容错 1.机制 在集群调用失败时,Dubbo 提供了多种容错方案,缺省为 failove ...

  6. UVA - 120Stacks of Flapjacks (摊煎饼。。)排序

    /* 这题使我记起了以前很多忘掉的东西,例如sstream(分割流),deque(双端队列),还有众多函数(STL里的).值得收藏 值得注意的是这题的序号问题,(因为要求输出翻转的位置),序号从右往左 ...

  7. ACM训练计划建议(转)

    ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...

  8. 机器学习之路: python k近邻分类器 KNeighborsClassifier 鸢尾花分类预测

    使用python语言 学习k近邻分类器的api 欢迎来到我的git查看源代码: https://github.com/linyi0604/MachineLearning from sklearn.da ...

  9. 用于兼容浏览器的js写法

    用于引用的源文件代码: var Common = { getEvent: function() {//ie/ff if (document.all) { return window.event; } ...

  10. 【差分约束系统/DFS版SPFA】BZOJ3436-小K的农场

    [题目大意] 总共n个农场,有以下三种描述:农场a比农场b至少多种植了c个单位的作物,农场a比农场b至多多种植了c个单位的作物,农场a与农场b种植的作物数一样多.问是否有可能性. [思路] 农场a比农 ...