如何从Lazarus 1.x中的字符串解析JSON

时间:2013-05-07 16:02:35

标签: json parsing lazarus fpc

Lazarus不是我最喜欢的开发工具:)

我有一个带有json数据的字符串,我如何解析它,并输出指定的键值?

use  ...., fpJSON, JSONParser;   
...
var jsonstring:string;
jsonstring:='[{"id":11,"text":"TEST","description":"Some text","created_at":"2012-04-26 01:50:29","state":"ACCEPTED"},{"id":49,"text":"TEST2","description":"Description test","created_at":"2012-05-01 19:16:43","state":"ACCEPTED"}]'
....
//how print all key 'text' with value (foreach all items and print 'text' and value only)
....

1 个答案:

答案 0 :(得分:0)

您是否尝试在FPC和Lazarus目录中搜索JSON?应该有比赛的植物(至少在我的Lazarus CodeTyphon版本中有)。另外,这里有一些链接可以帮助您入门:

  1. http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tools/jsonviewer/?root=lazarus&sortby=date
  2. http://code.google.com/p/json-fpk/
  3. http://www.lazarus.freepascal.org/index.php/topic,18348.msg103550.html#msg103550
  4. http://www.lazarus.freepascal.org/index.php/topic,17393.msg95829.html#msg95829