Question by
viciousesque · Aug 07, 2016 at 12:06 AM ·
json
Parsing Remote JSON
I was having an issue parsing JSON data using JsonUtility.FromJson retrieved from a remote server via WWW.
When loading the same file locally JsonUtility.FromJson parsed the data file fine, but when pulling the same file from a remote server, I received a "Invalid Value" error when invoking JsonUtility.FromJson.
The answer came from this post, http://answers.unity3d.com/questions/844423/wwwtext-not-reading-utf-8-text.html
Basically after receiving the response from the server, don't use WWW.text, instead use WWW.bytes and shave off the first three bytes, thusly:
string jsonString;
jsonString = System.Text.Encoding.UTF8.GetString(contentData.bytes, 3, contentData.bytes.Length - 3);
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612090308im_/https://answers.unity.com/themes/thub/images/avi.jpg)