Guest:
Register
|
Login
|
Member List
|
Search
|
Statistics
|
FAQ
Language
----------
Simplifed Chinese
Traditional Chinese
English
CnPack Forum
»
技术板块灌水区
» delphi的开源json库:superobject,用法简介
‹‹ Last Thread
|
Next Thread ››
Poll
Trade
Reward
Activity
Printable Version
|
Email to Friend
|
Subscription
|
Favorites
Subject: delphi的开源json库:superobject,用法简介
zzzl
(早安的空气)
版主
UID 590
Digest Posts 0
Credits 399
Posts 199
点点分 399
Reading Access 100
Registered 2004-11-29
Status Offline
#1
Post at 2009-9-28 21:50
Profile
|
Blog
|
P.M.
|
delphi的开源json库:superobject,用法简介
var
j, a: ISuperObject; //不能是TSuperObject,尽管有TSuperObject这个类,但这里就是要这样无厘头。
begin
j:=TSuperObject.Create(stObject); //创建一个json对象,如果参数是stArray,j就是一个json数组,参数还可以是其它的变量类型,比如字符串,数值之类的,看起来很强大,但是如果参数是一个描述了json的字符串的话,你会得到一个错误。如果想从文本加载,用j:=SO(json文本);
j.I['数字']:=123; //就等于 {"数字": 123} ,类似的,I还可以变成S,B,C之类的,以表示字符串,布尔型,货币型。
j.S['{字符串}']:="值"; //这是个bug:带有花括号时没有任何效果。
a:=TSuperObject.Create(stArray); //创建一个json数组a
a.I['']:=111; //表示给a数组添加一个111元素。注意[]中的值为'',在数组中其[]的语义进行了颠覆性的改变。
a.I[2]:="s"; //第3个元素值为"s",嗯,[]在superobject的用法还真多
j['arr']:=a; //把数组a添加进j,其key名为arr
showmessage( j.toJson() ); //查看j的json文本
j:=nil; //不能写j.Free
end;
jAmEs_
灌水部部长
UID 886
Digest Posts 0
Credits 1134
Posts 600
点点分 1134
Reading Access 10
Registered 2005-6-5
Location 广东
Status Offline
#2
Post at 2009-9-29 10:44
Profile
|
Blog
|
P.M.
易用性還不錯
Poll
Trade
Reward
Activity
CnPack Forum
CnPack English Forum
> CnWizards IDE Wizards
> CVSTracNT
> Announcements & Others
All times are GMT++8, the time now is 2024-11-24 09:43
Powered by
Discuz!
5.0.0
© 2001-2006
Comsenz Inc.
Processed in 0.008392 second(s), 9 queries , Gzip enabled
TOP
Clear Cookies
-
Contact Us
-
CnPack Website
-
Archiver
-
WAP
Member's CP Home
Edit Profile
Credits Transaction
Public User Groups
Buddy List
Main
Page Views
User Agents
Posts History
Top Forums
Top Threads
Post Ranking
Credit Ranking
Online Time
Team
Moderation Stats