0

My drupal developer given a url like:http://feed.local/feed/services/rest/viewget/test.json then am getting the out put as(when am browsing from chrome browser) below:

[{"nid":"133","node_title":"What is life really all about?"},{"nid":"139","node_title":"What went wrong?"}]

I am using sumitk tutorial that is how to develop iphone app using drupal as base system with titanium. My problem is how can i parse the above in titanium .Can any one help..... Or else If any one help me how can i use this in xcode........

Laxman13
  • 5,226
  • 3
  • 23
  • 27
thirupathi
  • 47
  • 10

2 Answers2

1

You can use Titanium.JSON.parse

Muhammad Zeeshan
  • 8,722
  • 10
  • 45
  • 55
  • See these links http://stackoverflow.com/questions/3165290/how-to-parsing-json-object-in-iphone-sdk-xcode-using-json-framework or http://stackoverflow.com/questions/692247/how-to-parse-nested-json-objects-with-json-framework-and-objective-c-iphone-xcod – Muhammad Zeeshan Nov 01 '11 at 13:34
  • [{"nid":"133","node_title":"What is life really all about?"},{"nid":"139","node_title":"What went wrong?"}] how can i place "node_title" in table view...? Can u help......that above json is coming from url..... – thirupathi Nov 02 '11 at 08:38
  • When you will extract out the json data, you can put it in table view as a label or row title. – Muhammad Zeeshan Nov 02 '11 at 09:32
0

JSON.parse will help you, it is a function included by Titanium. Make sure you encapsulate it within a try {} catch(excp) {}

For example:

try
{
   var data = JSON.parse('[{"nid":"133","node_title":"What is life really all about?"},{"nid":"139","node_title":"What went wrong?"}]');
}
catch (excp)
{
   alert('JSON parse error');
}
Steven Lu
  • 2,150
  • 1
  • 24
  • 33