iPhone json parsing problem - iphone

When I try to parse ( http://www.roundmenu.com/webservices/index.cfm?ws=listrst&filter=featured ) webservice in json I encounter issues.
If any one can find out what the problem please let me know.
thanks in advance.

That’s not valid JSON. As usual, it’s useful to validate JSON input via http://jsonlint.com.
That particular JSON input fails to properly escape double quotes (\") inside strings.

Put the response in a json formatter like this one on curiousconcept.com. It yields many errors, does look like it's invalid json.

Related

How to get data from queryResult->getFulfillmentMessages() Dialogflow v2

I am using the google/cloud-dialogflow library for php.
I can not get the data from $queryResult->getFulfillmentMessages(); I don't know how.
I have tried:
json_decode($queryResult->getFulfillmentMessages()->serializeToJsonString(), true);
But it shows me a error. I hope you can help me.
This solution worked for me. The response that is received from the queryResult is a protobuf repeated field. The payload that is required to be extracted can be accessed by calling the first element of the repeated field and serializing it to JSON string then decoding it.
json_decode($queryResult->getFulfillmentMessages()[0]->serializeToJsonString(), true);
This will give the payload in array format using which you can perform your operations on it.

How to parse JSON like variable in Perl?

I read from a WEB server which returns me data like this:
{'status':{"t":1, "f":1, "p":2, "i":1}}
It seems not a valid JSON format data, told by JSON::XS. How can I parse that?
JSON::XS doesn't seem to have a toggle for accepting single quotes, but JSON does.
use strict;
use warnings;
use JSON -support_by_pp
my $source = q( {'status':{"t":1, "f":1, "p":2, "i":1}} );
my $parsed = JSON->new->allow_singlequote->decode($source);
For more options and details, see the JSON module docs.
You can check the specification for the JSON format here. In your case, the problem is likely the single quotes around status. If you use regular double quotes instead, it should parse:
{"status":{"t":1, "f":1, "p":2, "i":1}}
You can check the validity of your JSON at http://jsonlint.com/
It's valid JavaScript. So if you don't want to write your own parser, pass it to a JavaScript engine for evaluation and conversion to JSON.

Objective C error 3840 - bad JSON apparently but it validates with JSlint

I have read around and this error seems to be from bad JSON. Easy enough, here is my JSON
{"year":"2012","wheels":"Standard","trans":"Unknown"}
My issue is, this appears to be correct, and when I run it through JSON lint it returns vaild. I have also used cURL to download this page and used json_decode() to read it...worked fine.
Here is an example page: http://drivingthenation.com/app/carlist/getVinDtn.php?v=JA3215H1C**M&f=v
I ran it through HTTPScoop and the only thing the response text returned was
{"year":"2012","wheels":"Standard","trans":"Unknown"}
On the objective-c end I am using NSURL and NSData to get the URL, and then NSJSONSerialization. I can print out before NSJSONSerialization and see that it is infact getting data, but this error only occurs when I try to format it into JSON. Any thoughts?
The NSJSONSerialization class, by default, expects the input to be not just valid JSON, but a valid JSON object. If you want to read something that's not an object, you need to specify the NSJSONReadingAllowFragments option to the reader.

Urls Which return JSON object?

can anybody give me the urls which return the JSON objects or we can say application/json to end user?
http://codeasp.net/articles/asp-net/222/how-to-shorten-url-with-jquery
http://codeasp.net/articles/asp-net/217/calling-web-service-using-jquery-in-asp-net
http://codeasp.net/articles/asp-net/214/cascading-dropdownlist-using-jquery-and-asp-net
http://codeasp.net/articles/asp-net/212/using-jquery-autocomplete-in-asp-net
#Raman Rana try this
http://www.unpossible.com/misc/lucky_numbers.json
This will return some numbers and for more information follow the tutorial....
http://mobileorchard.com/tutorial-json-over-http-on-the-iphone/
Hope this may help u!
If you are referring to this question, it seems that Weather.com does not support JSON (from my Googling).
You may need to use a different service, or convert the XML to JSON, or just read the XML.
The mime type application/json is returned, not sent as part of the request.

Converting String values to xml

I have some string values that are retrieved from json data. I need a process of converting this strings to xml format and Post it to a url
If it's inside iPhone SDK you will have to parse the string to convert it to XML, unless you can just post the xml as-is.
Anyway. To parse the XML, you have basically two easy options:
NSXMLParser
libxml2 (my preferred choice, don't know why)
Then you can use NSURLConnection class to post the information to the desired XML. There are a lot of Stackoverflow questions already covering this issue you can search and use.
You can also look at an example here.