1

I tried like this:

if (result.IsSuccessStatusCode)
{
    var content = await result.Content.ReadAsStringAsync();
    var content2 = await result2.Content.ReadAsStringAsync();

    sVm._matchStatistic = JsonConvert.DeserializeObject<MatchStatisticsModel>(content);
    sVm._funModel = JsonConvert.DeserializeObject<FunModel>(content2);
                
    return sVm;
}

but I get an error

Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

After that I will refresh the page the results are coming but, sometimes I get this error and sometimes it comes completely.

public class Fact
{
    [JsonProperty("statement")]
    public string statement { get; set; }
}

public class FunModel
{
    [JsonProperty("generated_at")]
    public DateTime generated_at { get; set; }

    [JsonProperty("facts")]
    public IList<Fact> facts { get; set; }
}

Here is my model and my json

{
    "generated_at": "2020-12-06T12:07:02+00:00",
    "facts": [
        {
            "statement": "Yalovaspor bu sezon evinde oynad\u0131\u011f\u0131 ma\u00e7larda: 0-1-4."
        },
        {
            "statement": "Yeni Altindag Belediyespor bu sezon deplasmanda oynad\u0131\u011f\u0131 ma\u00e7larda: 0-1-3."
        }
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
mko1995
  • 15
  • 3
  • Looks like your JSON is missing the closing ```}``` – derekbaker783 Dec 06 '20 at 14:24
  • Are you sure, the server always returns this json? The error shows an unexpected symbol of `<` which makes me suspect, the server may return some html. Furthermore your json is not valid. The `facts` array is missing the closing `]` – derpirscher Dec 06 '20 at 15:01
  • Check this link, if it is useful for you https://stackoverflow.com/questions/23259173/unexpected-character-encountered-while-parsing-value – Dhrumil shah Dec 08 '20 at 08:09

0 Answers0