JSON Parsing Error? - iphone

I am using JSON (SBJson) but it's giving the error :
JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading character\" UserInfo=0x5f2f7f0 {NSLocalizedDescription=Unrecognised leading character}.
am using this web service : "http://xoap.weather.com/search/search?where=India"
please give me the solutions why does error come?

That URL returns XML, not JSON. The "illegal character" is the first bracket in the XML, which isn't a valid character in JSON.

That response is XML (application/xml), not JSON (application/json).

Related

lexical error: malformed number, a digit is required after the minus sign?

I am getting the following response when trying to POST an object to an index:
{
"message": "lexical error: malformed number, a digit is required after the minus sign. Around '------WebK' near line:1 column:1", "status": 400
}
What can I do to fix this?
You need to POST your data as JSON to the API endpoint, not as a form-data form submission.

JMeter GWT Escape Character Exception

I'm trying a test in JMeter for requests that include a regular expression in its body. Trying to re-run the test, I get the below exception:
//EX[,,["com.google.gwt.user.client.rpc.IncompatibaleRemoteServiceException", "Unexpected escape character after backslash
The request body under the recording controller looks something like:
^([\w\-\.\'+]+)#(([([0-9]{1,3}\.){3}[0-9]{1,3}]))
While the request in "View Results Tree" is like:
^([\w-.\']+)#(([([0-9]{1,3}.){3}[0-9]{1,3}]))
Can anyone help please?

How do output for tRESTClient

I read some param from JSON file and for each param i should send request.
That when i true move output to any element i get errors:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
statusCode cannot be resolved or is not a field
string cannot be resolved or is not a field
body cannot be resolved or is not a field
The method getHeaders() is undefined for the type Response
at pricing.pricing_0_1.Pricing.tFileInputJSON_1Process(Pricing.java:3334)
at pricing.pricing_0_1.Pricing.tREST_1Process(Pricing.java:1783)
at pricing.pricing_0_1.Pricing.runJobInTOS(Pricing.java:4634)
at pricing.pricing_0_1.Pricing.main(Pricing.java:4366)
I had the same error messages (also having JSON files as input and output) and I found that the solution is to leave the Input, Response and Error Schema with the structures they initially had in tRESTClient.
The Input Schema contains body and string. Here you can either use tXMLMap to define the body structure (this didn't work for me) or send the JSON file as a string with tMap directly into the tRESTClient.
The Response has the schema statusCode, body and string. Again, just retrieving the string with a tMap and tLogRow will get you the output of tRestClient.
I hope this helps.
Include the statusCode variable in the JSON
I too got the same error, what I came across is since trestclient is expecting the schema inputs in form of stausCode , body and String.
Whereas the input is fed as key and value pair of schema. So we are getting error as enter image description here
So I used a tconvertType and converted the outgoing row from tconverttype as stausCode , body and String, and it started working.
enter image description here
and all the errors went away.
Thanks,

JSON Value failed

I am fetching data from server into my iPhone app.
But it shows the exception
-JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=4 \"Valid fragment, but not JSON\" UserInfo=0x6e9b460 {NSLocalizedDescription=Valid fragment, but not JSON}"
Any Solution.
Check your data should be in this format use http://jsonformatter.curiousconcept.com/ to check the json format

how to place arabic in NSURLConnection

I have to put arabic in NSURLConnection, but the problem is that when I am not able to see arabic string properly using NSLog I get following string.
Country is الإمارات العربية المتحدة
and if I pass from NSURLConnection I get
http://xxxxxx.com/api/api.php?func=showAllCompaniesCategoriesCountryWise&params[]=الإمارات العربية المتحدة&params[]=all
bad URL
Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x2f0b00 {NSUnderlyingError=0x2f1130 "bad URL", NSLocalizedDescription=bad URL}
So, please help me, how can I solve this problem.
You should use - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding to create a proper string for NSURL.