简体   繁体   English

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

[英]How parse JSON from string in Lazarus 1.x

Lazarus is not my favorite dev tool :) 拉撒路不是我最喜欢的开发工具:)

i have a string with json data, how i can parse it, and output specified key,value? 我有一个带有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)
....

Have you tried to search for JSON in your FPC and Lazarus directories? 您是否尝试过在FPC和Lazarus目录中搜索JSON? There should be planty of matches (at least there are in my Lazarus CodeTyphon edition). 应该有一些比赛(至少在我的Lazarus CodeTyphon版本中有)。 Alternatively, here are the links to get you started: 另外,以下是可帮助您入门的链接:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM