- Home /
The question is answered, right answer was accepted
Can't use JSON in WWW class iOS
Hello everyone. Maybe someone can help me with this, because i have no idea what's wrong. (sorry for my bad eng =)
So, i have client and php server and use JSON to make requests from client and do answers from server. (I'm sure, all scripts i wrote is good and have no errors)
In client-side i generate new WWW class with link to my server:
http://myserver.com/index.php?DATA={*JSON_HERE*}&HASH=*HASH_HERE*
And at server-side i generate JSON answer and just use "print $json", so i can catch this response by looking in www.text string.
And all i made was good and worked fine until i started to build it on my iPad. Build process have no errors and application works good, but no answer was received from server. I spend a lot time searching what's wrong and i found it!
I found that my WWW class returns null when i try to access www.text and it happens only when URL string have JSON inside, so if i use:
http://myserver.com/index.php?DATA=*SOME_VALUE*&HASH=*HASH_HERE*
that works, and if i try to use:
http://myserver.com/index.php?DATA={*JSON_HERE*}&HASH=*HASH_HERE*
that will not work, and looks like just nothing happens. In both ways www.isDone will become True, but it will be empty if request link was with JSON value...
That's not server-side mistakes, i tried same link in usual browser and all works fine, also PC / MAC / Android compilations works fine, that happens only in iOS device.
I work on latest Unity Pro 4.3.1 f1 and Xcode 5.0.2.
Thanks a lot for helping.
Answer by Graham-Dunnett · Dec 09, 2013 at 10:00 PM
Check out:
http://www.ietf.org/rfc/rfc1738.txt
Search for "unsafe" in that. You'll learn that braces are considered unsafe and should be escaped. Just because your browser lets you get away with this doesn't mean that it's safe to use. So, yes, it's not server side mistake, it's client side mistake.
$$anonymous$$y god, haven't thought about "unsafe" characters because all other compilations was with no errors. -_- Thank you man, after escaping my url all become perfect!
Follow this Question
Related Questions
Social when no image is set by the user 1 Answer
iOS Unity Remote For iPhone 5 0 Answers
Screen overlay effect is black on iOS 0 Answers
Audio not playing on iPad using Unity Remote 4 2 Answers
Publishing iOs app with Unity running in VirtualBox? 1 Answer