json,System.JSON,REST.JSON
JSON有两种数据结构,对象和数组。
对象在js中表示为“{}”括起来的内容,数据结构为 {key:value,key:value,...}
数组在js中是中括号“[]”括起来的内容,数据结构为 ["java","javascript","vb",...]
{
"NAME":"DVAD",
"SEX":"MAN",
"AGE":12
}
{"success":true}
"{\"success\":true}"
https://community.embarcadero.com/blogs/entry/how-to-make-restful-webbroker-using-c-builder
jo用完记得释放 jo.free;
root['child.name']
http://docwiki.embarcadero.com/Libraries/Berlin/en/System.JSON.TJSONObject
一、 System.Json.Readers JSONWriter
System.Json.Readers,System.Json.Writers, System.Json.Types
TJsonReader\TJsonTextWriter,与.net的Newtonsoft JsonTextReader 、JsonTextWriter相同,是RAD10 Settle版新增的功能。
http://docwiki.embarcadero.com/CodeExamples/Berlin/en/RTL.JSONWriter
System.JSON.Writers.hpp
生成的json字符串
{ "id": "001", "name": "aaa", "age": 99 }
procedure TFrmLogin.Button2Click( Sender : TObject ); var writer : TJsonTextWriter; sw : TStringWriter; begin sw := TStringWriter.Create; writer := TJsonTextWriter.Create( sw ); writer.Formatting := TJsonFormatting.Indented; writer.WriteStartObject; writer.WritePropertyName( 'id' ); writer.WriteValue( '001' ); writer.WritePropertyName( 'name' ); writer.WriteValue( 'aaa' ); writer.WritePropertyName( 'age' ); writer.WriteValue( 99 ); writer.WriteEndObject; self.Memo1.Text := sw.ToString; sw.Free; end;