Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
corbinyo opened this issue Dec 30, 2019 · 0 comments

Comments

@corbinyo
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant