LitJSON/litjson

How do I fix “Invalid character '' in input string at LitJson.Lexer.NextToken ()” when trying to use JSON from URL?

corbinyo opened this issue · 0 comments

When trying to use a Json file served by a url I am getting the error

JsonException: Invalid character '' in input string
it happens when I use this method:

IEnumerator GetText()
{
   UnityWebRequest webjson = UnityWebRequest.Get("http://awebsite.com/Art_.json");

    yield return webjson.SendWebRequest();

    if (webjson.isNetworkError || webjson.isHttpError)
    {
        Debug.Log(webjson.error);
    }
    else
    {
        // The following line is giving me the error:
        // ItemDatabase_+<GetText>d__3.MoveNext () (at Assets/Version2.0/Scripts/ItemDatabase_.cs:38)
        itemData = JsonMapper.ToObject(webjson.downloadHandler.text);

        Debug.Log(itemData);

        ConstructItemDatabase();

    }
}

I have tried to use Trim()

itemData = JsonMapper.ToObject(webjson.downloadHandler.text.Trim());
But still have the same result.