- Home /
WWW object has doesnt return the full string
Im trying to fetch a JSON from this service: http://haimtest.azurewebsites.net/MuseumService.asmx/GetNews
you can see that in the browser it returns a pretty long json.
tried to get it into unity in UTF-8 charset with this code:
IEnumerator GetNews()
{
WWW www = new WWW("http://haimtest.azurewebsites.net/MuseumService.asmx/GetNews");
while(!www.isDone)
yield return 0;
Debug.Log(www.text);
Debug.Log(www.size);
}
the problem is that www.text doesnt have the full text that the service returns but only the first 454 chars of it:
Answer by SubatomicHero · Jun 03, 2013 at 02:46 PM
I think you may need to alter the code to look like this:
IEnumerator GetNews() {
WWW www = new WWW("http://haimtest.azurewebsites.net/MuseumService.asmx/GetNews");
yield return www;
Debug.Log(www.text);
Debug.Log(www.size);
}
I also tried it that way because i find the while yield return 0 way strange. but the result is the same
Answer by Haimmer · Jun 03, 2013 at 03:38 PM
Ok i found the problem. The service returned a text in utf-8 but something went wrong with the encoding there and for some reason the browser read it ok but unity didnt.
i just encoded the string differently on the service to return this: Context.Response.Write(Encoding.UTF8.GetString(encodedBytes));
insted of just a string
Your answer
Follow this Question
Related Questions
Encode String to URL friendly format 2 Answers
WWW & and strings in C# 1 Answer
Maximum WWW.text fetch size 1 Answer
Display Movie Name From www Address With A UI Text? 0 Answers
If Statement Acting Strange 1 Answer