1

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)
....
4

1 回答 1

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
于 2013-05-08T10:21:01.757 回答