Ошибка unexpected character encountered while parsing value path line 0 position 0

Currently, I have some issues. I’m using C# with Json.NET. The issue is that I always get:

{«Unexpected character encountered while parsing value: e. Path », line 0, position 0.»}

So the way I’m using Json.NET is the following. I have a Class which should be saved. The class looks like this:

public class stats
{
    public string time { get; set; }
    public string value { get; set; }
}

public class ViewerStatsFormat
{
    public List<stats> viewerstats { get; set; }
    public String version { get; set; }

    public ViewerStatsFormat(bool chk)
    {
        this.viewerstats = new List<stats>();
    }
}

One object of this class will be filled and saved with:

 File.WriteAllText(tmpfile, JsonConvert.SerializeObject(current), Encoding.UTF8);

The saving part works fine and the file exists and is filled. After that the file will be read back into the class with:

try 
{ 
    ViewerStatsFormat current = JsonConvert.DeserializeObject<ViewerStatsFormat>(tmpfile);
    //otherstuff        
}
catch(Exception ex)
{
    //error loging stuff
}

Now on the current= line comes the exception:

{«Unexpected character encountered while parsing value: e. Path », line 0, position 0.»}

I don’t know why this comes. The JSON file is the following -> Click me I am the JSON link

Does anyone have any ideas?

Djordje Nedovic's user avatar

asked Apr 24, 2014 at 3:16

zAfLu's user avatar

7

Possibly you are not passing JSON to DeserializeObject.

It looks like from File.WriteAllText(tmpfile,... that type of tmpfile is string that contain path to a file. JsonConvert.DeserializeObject takes JSON value, not file path — so it fails trying to convert something like @"c:tempfooo" — which is clearly not JSON.

MrBoJangles's user avatar

MrBoJangles

12.1k17 gold badges61 silver badges79 bronze badges

answered Apr 24, 2014 at 3:23

Alexei Levenkov's user avatar

Alexei LevenkovAlexei Levenkov

98.7k13 gold badges127 silver badges179 bronze badges

1

I solved the problem with these online tools:

  1. To check if the Json structure is OKAY: http://jsonlint.com/
  2. To generate my Object class from my Json structure: https://www.jsonutils.com/

The simple code:

RootObject rootObj= JsonConvert.DeserializeObject<RootObject>(File.ReadAllText(pathFile));

answered Mar 4, 2016 at 21:02

Eduardo Pelais's user avatar

2

In my case, the file containing JSON string had BOM. Once I removed BOM the problem was solved.

enter image description here

answered Dec 29, 2019 at 19:19

Aleksei Mialkin's user avatar

Aleksei MialkinAleksei Mialkin

2,2371 gold badge27 silver badges25 bronze badges

3

I experienced the same error in my Xamarin.Android solution.

I verified that my JSON was correct, and noticed that the error only appeared when I ran the app as a Release build.

It turned out that the Linker was removing a library from Newtonsoft.JSON, causing the JSON to be parsed incorrectly.

I fixed the error by adding Newtonsoft.Json to the Ignore assemblies setting in the Android Build Configuration (screen shot below)

JSON Parsing Code

static readonly JsonSerializer _serializer = new JsonSerializer();
static readonly HttpClient _client = new HttpClient();

static async Task<T> GetDataObjectFromAPI<T>(string apiUrl)
{
    using (var stream = await _client.GetStreamAsync(apiUrl).ConfigureAwait(false))
    using (var reader = new StreamReader(stream))
    using (var json = new JsonTextReader(reader))
    {
        if (json == null)
            return default(T);

        return _serializer.Deserialize<T>(json);
    }
}

Visual Studio Mac Screenshot

enter image description here

Visual Studio Screenshot

enter image description here

answered Feb 18, 2017 at 8:51

Brandon Minnick's user avatar

Brandon MinnickBrandon Minnick

13.2k15 gold badges65 silver badges121 bronze badges

0

I have also encountered this error for a Web API (.Net Core 3.0) action that was binding to a string instead to an object or a JObject. The JSON was correct, but the binder tried to get a string from the JSON structure and failed.

So, instead of:

[HttpPost("[action]")]
public object Search([FromBody] string data)

I had to use the more specific:

[HttpPost("[action]")]
public object Search([FromBody] JObject data)

answered Nov 23, 2019 at 9:51

Alexei - check Codidact's user avatar

2

This issue is related to Byte Order Mark in the JSON file. JSON file is not encoded as UTF8 encoding data when saved. Using File.ReadAllText(pathFile) fix this issue.

When we are operating on Byte data and converting that to string and then passing to JsonConvert.DeserializeObject, we can use UTF32 encoding to get the string.

byte[] docBytes = File.ReadAllBytes(filePath);

string jsonString = Encoding.UTF32.GetString(docBytes);

Minzkraut's user avatar

Minzkraut

2,12924 silver badges31 bronze badges

answered Feb 1, 2018 at 8:34

Praveen's user avatar

PraveenPraveen

1472 silver badges5 bronze badges

I had the same problem with webapi in ASP.NET core, in my case it was because my application needs authentication, then it assigns the annotation [AllowAnonymous] and it worked.

[AllowAnonymous]
public async Task <IList <IServic >> GetServices () {
        
}

Joey's user avatar

Joey

1,4262 gold badges19 silver badges33 bronze badges

answered Apr 17, 2019 at 11:57

Celso Xavier Luz's user avatar

1

I ran into this issue and it ended up being because of BOM characters in my input string.

Here’s what I ended up doing:

String.Trim(new char[] { 'uFEFF', 'u200B' });

This resolved the issue for me.

answered Oct 26, 2021 at 15:21

Jayesh Modha's user avatar

In my case, I was getting an error on JsonConvert.PopulateObject().
My request was returning JSON that was wrapped in an extra pair of ‘[ ]’ brackets, making my result an array of one object rather than just an object. Here’s what I did to get inside these brackets (only for that type of model):

           T jsonResponse = new T();
           var settings = new JsonSerializerSettings
           {
               DateParseHandling = DateParseHandling.DateTimeOffset,
               NullValueHandling = NullValueHandling.Ignore,
           };
           var jRslt = response.Content.ReadAsStringAsync().Result;
           if (jsonResponse.GetType() == typeof(myProject.Models.MyModel))
           {
               var dobj = JsonConvert.DeserializeObject<MyModel[]>(jRslt);
               var y = dobj.First();
               var szObj = JsonConvert.SerializeObject(y);
               JsonConvert.PopulateObject(szObj, jsonResponse, settings);
           }
           else
           {
               JsonConvert.PopulateObject(jRslt, jsonResponse);
           }

answered Nov 12, 2019 at 16:04

pkucas's user avatar

pkucaspkucas

1595 bronze badges

If you are using downloading data using url…may need to use

var result = client.DownloadData(url);

Liam's user avatar

Liam

27.3k28 gold badges126 silver badges187 bronze badges

answered Mar 23, 2017 at 20:08

Taran's user avatar

TaranTaran

2,82524 silver badges22 bronze badges

In my scenario I had a slightly different message, where the line and position were not zero.

E. Path ‘job[0].name’, line 1, position 12.

This was the top Google answer for the message I quoted.

This came about because I had called a program from the Windows command line, passing JSON as a parameter.

When I reviewed the args in my program, all the double quotes got stripped.
You have to reconstitute them.

I posted a solution here. Though it could probably be enhanced with a Regex.

answered May 2, 2019 at 11:31

JGFMK's user avatar

JGFMKJGFMK

8,3154 gold badges56 silver badges92 bronze badges

I had a similar error and thought I’d answer in case anyone was having something similar. I was looping over a directory of json files and deserializing them but was getting this same error.

The problem was that it was trying to grab hidden files as well. Make sure the file you’re passing in is a .json file. I’m guessing it’ll handle text as well. Hope this helps.

answered Jul 22, 2019 at 16:06

Ibaeni's user avatar

IbaeniIbaeni

5510 bronze badges

I had simular problem. In my case the problem was in DateTime format. It was just numbers and it is also know as EpochFormat or UnixTimestamp.
A part from my JSON:

"direction": "outbound",
"date_archive": 1554691800224,
"date_doc": 1524700800000,
"date_sent": 1524704189000,
"date_received": 1524704189000,
"date_store_till": 1712544600224,

So I’ve used an attribute like this:

[JsonProperty("date_received")]
[JsonConverter(typeof(MicrosecondEpochConverter))]
public DateTime? DateReceived { get; set; }

You can find MicrosecondEpochConverter code here: https://stackoverflow.com/a/19972214/4324624

answered Apr 6, 2022 at 20:26

Vladislav's user avatar

VladislavVladislav

2081 silver badge12 bronze badges

I faced similar error message in Xamarin forms when sending request to webApi to get a Token,

  • Make sure all keys (key : value) (ex.’username’, ‘password’, ‘grant_type’) in the Json file are exactly what the webApi expecting, otherwise it fires this exception.

Unhandled Exception: Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path », line 0, position 0

answered Sep 7, 2018 at 6:42

A. Almazidi's user avatar

0

Please check the model you shared between client and server is same. sometimes you get this error when you not updated the Api version and it returns a updated model, but you still have an old one. Sometimes you get what you serialize/deserialize is not a valid JSON.

answered Feb 1, 2019 at 2:56

Nalan Madheswaran's user avatar

In my case, it was the lack of a default parameterless constructor !!!

answered Jan 14, 2022 at 23:17

A.B.'s user avatar

A.B.A.B.

2,3443 gold badges24 silver badges40 bronze badges

In my case, I was calling the async service method without using await, so before Task is completed I was trying to return the result!

answered Mar 1, 2022 at 0:53

EspressoCode's user avatar

Note that maybe your JSON contain extra " " in the values.

answered May 1 at 11:33

Majid's user avatar

MajidMajid

13.8k15 gold badges77 silver badges113 bronze badges

This error occurs when we parse json content to model object. Json content type is string.
For example:
https://dotnetfiddle.net/uFClKj
Some times, an api that we call may return an error. If we do not check the response status, but proceed to parse the response to model, this issue will occur.

shr's user avatar

shr

84510 silver badges20 bronze badges

answered Nov 7, 2020 at 9:13

Diem Nguyen's user avatar

Suppose this is your json

{
  "date":"11/05/2016",
  "venue": "{"ID":12,"CITY":Delhi}"
}

if you again want deserialize venue, modify json as below

{
  "date":"11/05/2016",
  "venue": "{"ID":"12","CITY":"Delhi"}"
}

then try to deserialize to respective class by taking the value of venue

answered May 11, 2016 at 7:35

Hrishikesh T T's user avatar

2

When I encountered a similar problem, I fixed it by substituting &mode=xml for &mode=json in the request.

ryanyuyu's user avatar

ryanyuyu

6,31710 gold badges48 silver badges52 bronze badges

answered Sep 26, 2016 at 12:42

AlfredBauer's user avatar

AlfredBauerAlfredBauer

1052 silver badges6 bronze badges

0

Currently, I have some issues. I’m using C# with Json.NET. The issue is that I always get:

{«Unexpected character encountered while parsing value: e. Path », line 0, position 0.»}

So the way I’m using Json.NET is the following. I have a Class which should be saved. The class looks like this:

public class stats
{
    public string time { get; set; }
    public string value { get; set; }
}

public class ViewerStatsFormat
{
    public List<stats> viewerstats { get; set; }
    public String version { get; set; }

    public ViewerStatsFormat(bool chk)
    {
        this.viewerstats = new List<stats>();
    }
}

One object of this class will be filled and saved with:

 File.WriteAllText(tmpfile, JsonConvert.SerializeObject(current), Encoding.UTF8);

The saving part works fine and the file exists and is filled. After that the file will be read back into the class with:

try 
{ 
    ViewerStatsFormat current = JsonConvert.DeserializeObject<ViewerStatsFormat>(tmpfile);
    //otherstuff        
}
catch(Exception ex)
{
    //error loging stuff
}

Now on the current= line comes the exception:

{«Unexpected character encountered while parsing value: e. Path », line 0, position 0.»}

I don’t know why this comes. The JSON file is the following -> Click me I am the JSON link

Does anyone have any ideas?

Djordje Nedovic's user avatar

asked Apr 24, 2014 at 3:16

zAfLu's user avatar

7

Possibly you are not passing JSON to DeserializeObject.

It looks like from File.WriteAllText(tmpfile,... that type of tmpfile is string that contain path to a file. JsonConvert.DeserializeObject takes JSON value, not file path — so it fails trying to convert something like @"c:tempfooo" — which is clearly not JSON.

MrBoJangles's user avatar

MrBoJangles

12.1k17 gold badges61 silver badges79 bronze badges

answered Apr 24, 2014 at 3:23

Alexei Levenkov's user avatar

Alexei LevenkovAlexei Levenkov

98.7k13 gold badges127 silver badges179 bronze badges

1

I solved the problem with these online tools:

  1. To check if the Json structure is OKAY: http://jsonlint.com/
  2. To generate my Object class from my Json structure: https://www.jsonutils.com/

The simple code:

RootObject rootObj= JsonConvert.DeserializeObject<RootObject>(File.ReadAllText(pathFile));

answered Mar 4, 2016 at 21:02

Eduardo Pelais's user avatar

2

In my case, the file containing JSON string had BOM. Once I removed BOM the problem was solved.

enter image description here

answered Dec 29, 2019 at 19:19

Aleksei Mialkin's user avatar

Aleksei MialkinAleksei Mialkin

2,2371 gold badge27 silver badges25 bronze badges

3

I experienced the same error in my Xamarin.Android solution.

I verified that my JSON was correct, and noticed that the error only appeared when I ran the app as a Release build.

It turned out that the Linker was removing a library from Newtonsoft.JSON, causing the JSON to be parsed incorrectly.

I fixed the error by adding Newtonsoft.Json to the Ignore assemblies setting in the Android Build Configuration (screen shot below)

JSON Parsing Code

static readonly JsonSerializer _serializer = new JsonSerializer();
static readonly HttpClient _client = new HttpClient();

static async Task<T> GetDataObjectFromAPI<T>(string apiUrl)
{
    using (var stream = await _client.GetStreamAsync(apiUrl).ConfigureAwait(false))
    using (var reader = new StreamReader(stream))
    using (var json = new JsonTextReader(reader))
    {
        if (json == null)
            return default(T);

        return _serializer.Deserialize<T>(json);
    }
}

Visual Studio Mac Screenshot

enter image description here

Visual Studio Screenshot

enter image description here

answered Feb 18, 2017 at 8:51

Brandon Minnick's user avatar

Brandon MinnickBrandon Minnick

13.2k15 gold badges65 silver badges121 bronze badges

0

I have also encountered this error for a Web API (.Net Core 3.0) action that was binding to a string instead to an object or a JObject. The JSON was correct, but the binder tried to get a string from the JSON structure and failed.

So, instead of:

[HttpPost("[action]")]
public object Search([FromBody] string data)

I had to use the more specific:

[HttpPost("[action]")]
public object Search([FromBody] JObject data)

answered Nov 23, 2019 at 9:51

Alexei - check Codidact's user avatar

2

This issue is related to Byte Order Mark in the JSON file. JSON file is not encoded as UTF8 encoding data when saved. Using File.ReadAllText(pathFile) fix this issue.

When we are operating on Byte data and converting that to string and then passing to JsonConvert.DeserializeObject, we can use UTF32 encoding to get the string.

byte[] docBytes = File.ReadAllBytes(filePath);

string jsonString = Encoding.UTF32.GetString(docBytes);

Minzkraut's user avatar

Minzkraut

2,12924 silver badges31 bronze badges

answered Feb 1, 2018 at 8:34

Praveen's user avatar

PraveenPraveen

1472 silver badges5 bronze badges

I had the same problem with webapi in ASP.NET core, in my case it was because my application needs authentication, then it assigns the annotation [AllowAnonymous] and it worked.

[AllowAnonymous]
public async Task <IList <IServic >> GetServices () {
        
}

Joey's user avatar

Joey

1,4262 gold badges19 silver badges33 bronze badges

answered Apr 17, 2019 at 11:57

Celso Xavier Luz's user avatar

1

I ran into this issue and it ended up being because of BOM characters in my input string.

Here’s what I ended up doing:

String.Trim(new char[] { 'uFEFF', 'u200B' });

This resolved the issue for me.

answered Oct 26, 2021 at 15:21

Jayesh Modha's user avatar

In my case, I was getting an error on JsonConvert.PopulateObject().
My request was returning JSON that was wrapped in an extra pair of ‘[ ]’ brackets, making my result an array of one object rather than just an object. Here’s what I did to get inside these brackets (only for that type of model):

           T jsonResponse = new T();
           var settings = new JsonSerializerSettings
           {
               DateParseHandling = DateParseHandling.DateTimeOffset,
               NullValueHandling = NullValueHandling.Ignore,
           };
           var jRslt = response.Content.ReadAsStringAsync().Result;
           if (jsonResponse.GetType() == typeof(myProject.Models.MyModel))
           {
               var dobj = JsonConvert.DeserializeObject<MyModel[]>(jRslt);
               var y = dobj.First();
               var szObj = JsonConvert.SerializeObject(y);
               JsonConvert.PopulateObject(szObj, jsonResponse, settings);
           }
           else
           {
               JsonConvert.PopulateObject(jRslt, jsonResponse);
           }

answered Nov 12, 2019 at 16:04

pkucas's user avatar

pkucaspkucas

1595 bronze badges

If you are using downloading data using url…may need to use

var result = client.DownloadData(url);

Liam's user avatar

Liam

27.3k28 gold badges126 silver badges187 bronze badges

answered Mar 23, 2017 at 20:08

Taran's user avatar

TaranTaran

2,82524 silver badges22 bronze badges

In my scenario I had a slightly different message, where the line and position were not zero.

E. Path ‘job[0].name’, line 1, position 12.

This was the top Google answer for the message I quoted.

This came about because I had called a program from the Windows command line, passing JSON as a parameter.

When I reviewed the args in my program, all the double quotes got stripped.
You have to reconstitute them.

I posted a solution here. Though it could probably be enhanced with a Regex.

answered May 2, 2019 at 11:31

JGFMK's user avatar

JGFMKJGFMK

8,3154 gold badges56 silver badges92 bronze badges

I had a similar error and thought I’d answer in case anyone was having something similar. I was looping over a directory of json files and deserializing them but was getting this same error.

The problem was that it was trying to grab hidden files as well. Make sure the file you’re passing in is a .json file. I’m guessing it’ll handle text as well. Hope this helps.

answered Jul 22, 2019 at 16:06

Ibaeni's user avatar

IbaeniIbaeni

5510 bronze badges

I had simular problem. In my case the problem was in DateTime format. It was just numbers and it is also know as EpochFormat or UnixTimestamp.
A part from my JSON:

"direction": "outbound",
"date_archive": 1554691800224,
"date_doc": 1524700800000,
"date_sent": 1524704189000,
"date_received": 1524704189000,
"date_store_till": 1712544600224,

So I’ve used an attribute like this:

[JsonProperty("date_received")]
[JsonConverter(typeof(MicrosecondEpochConverter))]
public DateTime? DateReceived { get; set; }

You can find MicrosecondEpochConverter code here: https://stackoverflow.com/a/19972214/4324624

answered Apr 6, 2022 at 20:26

Vladislav's user avatar

VladislavVladislav

2081 silver badge12 bronze badges

I faced similar error message in Xamarin forms when sending request to webApi to get a Token,

  • Make sure all keys (key : value) (ex.’username’, ‘password’, ‘grant_type’) in the Json file are exactly what the webApi expecting, otherwise it fires this exception.

Unhandled Exception: Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path », line 0, position 0

answered Sep 7, 2018 at 6:42

A. Almazidi's user avatar

0

Please check the model you shared between client and server is same. sometimes you get this error when you not updated the Api version and it returns a updated model, but you still have an old one. Sometimes you get what you serialize/deserialize is not a valid JSON.

answered Feb 1, 2019 at 2:56

Nalan Madheswaran's user avatar

In my case, it was the lack of a default parameterless constructor !!!

answered Jan 14, 2022 at 23:17

A.B.'s user avatar

A.B.A.B.

2,3443 gold badges24 silver badges40 bronze badges

In my case, I was calling the async service method without using await, so before Task is completed I was trying to return the result!

answered Mar 1, 2022 at 0:53

EspressoCode's user avatar

Note that maybe your JSON contain extra " " in the values.

answered May 1 at 11:33

Majid's user avatar

MajidMajid

13.8k15 gold badges77 silver badges113 bronze badges

This error occurs when we parse json content to model object. Json content type is string.
For example:
https://dotnetfiddle.net/uFClKj
Some times, an api that we call may return an error. If we do not check the response status, but proceed to parse the response to model, this issue will occur.

shr's user avatar

shr

84510 silver badges20 bronze badges

answered Nov 7, 2020 at 9:13

Diem Nguyen's user avatar

Suppose this is your json

{
  "date":"11/05/2016",
  "venue": "{"ID":12,"CITY":Delhi}"
}

if you again want deserialize venue, modify json as below

{
  "date":"11/05/2016",
  "venue": "{"ID":"12","CITY":"Delhi"}"
}

then try to deserialize to respective class by taking the value of venue

answered May 11, 2016 at 7:35

Hrishikesh T T's user avatar

2

When I encountered a similar problem, I fixed it by substituting &mode=xml for &mode=json in the request.

ryanyuyu's user avatar

ryanyuyu

6,31710 gold badges48 silver badges52 bronze badges

answered Sep 26, 2016 at 12:42

AlfredBauer's user avatar

AlfredBauerAlfredBauer

1052 silver badges6 bronze badges

0

Solution 1:[1]

Possibly you are not passing JSON to DeserializeObject.

It looks like from File.WriteAllText(tmpfile,... that type of tmpfile is string that contain path to a file. JsonConvert.DeserializeObject takes JSON value, not file path — so it fails trying to convert something like @"c:tempfooo" — which is clearly not JSON.

Solution 2:[2]

I solved the problem with these online tools:

  1. To check if the Json structure is OKAY: http://jsonlint.com/
  2. To generate my Object class from my Json structure: https://www.jsonutils.com/

The simple code:

RootObject rootObj= JsonConvert.DeserializeObject<RootObject>(File.ReadAllText(pathFile));

Solution 3:[3]

In my case, the file containing JSON string had BOM. Once I removed BOM the problem was solved.

enter image description here

Solution 4:[4]

I experienced the same error in my Xamarin.Android solution.

I verified that my JSON was correct, and noticed that the error only appeared when I ran the app as a Release build.

It turned out that the Linker was removing a library from Newtonsoft.JSON, causing the JSON to be parsed incorrectly.

I fixed the error by adding Newtonsoft.Json to the Ignore assemblies setting in the Android Build Configuration (screen shot below)

JSON Parsing Code

static readonly JsonSerializer _serializer = new JsonSerializer();
static readonly HttpClient _client = new HttpClient();

static async Task<T> GetDataObjectFromAPI<T>(string apiUrl)
{
    using (var stream = await _client.GetStreamAsync(apiUrl).ConfigureAwait(false))
    using (var reader = new StreamReader(stream))
    using (var json = new JsonTextReader(reader))
    {
        if (json == null)
            return default(T);

        return _serializer.Deserialize<T>(json);
    }
}

Visual Studio Mac Screenshot

enter image description here

Visual Studio Screenshot

enter image description here

Solution 5:[5]

I have also encountered this error for a Web API (.Net Core 3.0) action that was binding to a string instead to an object or a JObject. The JSON was correct, but the binder tried to get a string from the JSON structure and failed.

So, instead of:

[HttpPost("[action]")]
public object Search([FromBody] string data)

I had to use the more specific:

[HttpPost("[action]")]
public object Search([FromBody] JObject data)

Solution 6:[6]

This issue is related to Byte Order Mark in the JSON file. JSON file is not encoded as UTF8 encoding data when saved. Using File.ReadAllText(pathFile) fix this issue.

When we are operating on Byte data and converting that to string and then passing to JsonConvert.DeserializeObject, we can use UTF32 encoding to get the string.

byte[] docBytes = File.ReadAllBytes(filePath);

string jsonString = Encoding.UTF32.GetString(docBytes);

Solution 7:[7]

I had the same problem with webapi in ASP.NET core, in my case it was because my application needs authentication, then it assigns the annotation [AllowAnonymous] and it worked.

[AllowAnonymous]
public async Task <IList <IServic >> GetServices () {
        
}

Solution 8:[8]

I ran into this issue and it ended up being because of BOM characters in my input string.

Here’s what I ended up doing:

String.Trim(new char[] { 'uFEFF', 'u200B' });

This resolved the issue for me.

Solution 9:[9]

In my scenario I had a slightly different message, where the line and position were not zero.

E. Path ‘job[0].name’, line 1, position 12.

This was the top Google answer for the message I quoted.

This came about because I had called a program from the Windows command line, passing JSON as a parameter.

When I reviewed the args in my program, all the double quotes got stripped.
You have to reconstitute them.

I posted a solution here. Though it could probably be enhanced with a Regex.

Solution 10:[10]

I had a similar error and thought I’d answer in case anyone was having something similar. I was looping over a directory of json files and deserializing them but was getting this same error.

The problem was that it was trying to grab hidden files as well. Make sure the file you’re passing in is a .json file. I’m guessing it’ll handle text as well. Hope this helps.

Solution 11:[11]

In my case, I was getting an error on JsonConvert.PopulateObject().
My request was returning JSON that was wrapped in an extra pair of ‘[ ]’ brackets, making my result an array of one object rather than just an object. Here’s what I did to get inside these brackets (only for that type of model):

           T jsonResponse = new T();
                var settings = new JsonSerializerSettings
                {
                    DateParseHandling = DateParseHandling.DateTimeOffset,
                    NullValueHandling = NullValueHandling.Ignore,
                };
                var jRslt = response.Content.ReadAsStringAsync().Result;
                if (jsonResponse.GetType() == typeof(myProject.Models.myModel))
                {
                    var dobj = JsonConvert.DeserializeObject<myModel[]>(jRslt);
                    var y = dobj.First();
                    var szObj = JsonConvert.SerializeObject(y);
                    JsonConvert.PopulateObject(szObj, jsonResponse, settings);
                }
                else
                {
                    JsonConvert.PopulateObject(jRslt, jsonResponse);
                }

Solution 12:[12]

If you are using downloading data using url…may need to use

var result = client.DownloadData(url);

Solution 13:[13]

Suppose this is your json

{
  "date":"11/05/2016",
  "venue": "{"ID":12,"CITY":Delhi}"
}

if you again want deserialize venue, modify json as below

{
  "date":"11/05/2016",
  "venue": "{"ID":"12","CITY":"Delhi"}"
}

then try to deserialize to respective class by taking the value of venue

Solution 14:[14]

I faced similar error message in Xamarin forms when sending request to webApi to get a Token,

  • Make sure all keys (key : value) (ex.’username’, ‘password’, ‘grant_type’) in the Json file are exactly what the webApi expecting, otherwise it fires this exception.

Unhandled Exception: Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path », line 0, position 0

Solution 15:[15]

Please check the model you shared between client and server is same. sometimes you get this error when you not updated the Api version and it returns a updated model, but you still have an old one. Sometimes you get what you serialize/deserialize is not a valid JSON.

Solution 16:[16]

This error occurs when we parse json content to model object. Json content type is string.
For example:
https://dotnetfiddle.net/uFClKj
Some times, an api that we call may return an error. If we do not check the response status, but proceed to parse the response to model, this issue will occur.

Solution 17:[17]

In my case, it was the lack of a default parameterless constructor !!!

Solution 18:[18]

In my case, I was calling the async service method without using await, so before Task is completed I was trying to return the result!

Solution 19:[19]

I had simular problem. In my case the problem was in DateTime format. It was just numbers and it is also know as EpochFormat or UnixTimestamp.
A part from my JSON:

"direction": "outbound",
"date_archive": 1554691800224,
"date_doc": 1524700800000,
"date_sent": 1524704189000,
"date_received": 1524704189000,
"date_store_till": 1712544600224,

So I’ve used an attribute like this:

[JsonProperty("date_received")]
[JsonConverter(typeof(MicrosecondEpochConverter))]
public DateTime? DateReceived { get; set; }

You can find MicrosecondEpochConverter code here: https://stackoverflow.com/a/19972214/4324624

Solution 20:[20]

When I encountered a similar problem, I fixed it by substituting &mode=xml for &mode=json in the request.

May 2023 Community Newsletter and Upcoming Events

Welcome to our May 2023 Community Newsletter, where we’ll be highlighting the latest news, releases, upcoming events, and the great work of our members inside the Biz Apps communities. If you’re new to this LinkedIn group, be sure to subscribe here in the News & Announcements to stay up to date with the latest news from our ever-growing membership network who «changed the way they thought about code».
 

 
 
 
LATEST NEWS
«Mondays at Microsoft» LIVE on LinkedIn — 8am PST — Monday 15th May  — Grab your Monday morning coffee and come join Principal Program Managers Heather Cook and Karuana Gatimu for the premiere episode of «Mondays at Microsoft»! This show will kick off the launch of the new Microsoft Community LinkedIn channel and cover a whole host of hot topics from across the #PowerPlatform, #ModernWork, #Dynamics365, #AI, and everything in-between. Just click the image below to register and come join the team LIVE on Monday 15th May 2023 at 8am PST. Hope to see you there!
 
 
Executive Keynote | Microsoft Customer Success Day
CVP for Business Applications & Platform, Charles Lamanna, shares the latest #BusinessApplications product enhancements and updates to help customers achieve their business outcomes.
 
 

 
 
S01E13 Power Platform Connections — 12pm PST — Thursday 11th May
Episode Thirteen of Power Platform Connections sees Hugo Bernier take a deep dive into the mind of co-host David Warner II, alongside the reviewing the great work of Dennis Goedegebuure, Keith Atherton, Michael Megel, Cat Schneider, and more.
Click below to subscribe and get notified, with David and Hugo LIVE in the YouTube chat from 12pm PST. And use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show.
 
 

 
 
UPCOMING EVENTS
 
European Power Platform Conference — early bird ticket sale ends!
The European Power Platform Conference early bird ticket sale ends on Friday 12th May 2023!
#EPPC23 brings together the Microsoft Power Platform Communities for three days of unrivaled days in-person learning, connections and inspiration, featuring three inspirational keynotes, six expert full-day tutorials, and over eighty-five specialist sessions, with guest speakers including April Dunnam, Dona Sarkar, Ilya Fainberg, Janet Robb, Daniel Laskewitz, Rui Santos, Jens Christian Schrøder, Marco Rocca, and many more. Deep dive into the latest product advancements as you hear from some of the brightest minds in the #PowerApps space.
Click here to book your ticket today and save! 
 
 

DynamicMinds Conference — Slovenia — 22-24th May 2023
It’s not long now until the DynamicsMinds Conference, which takes place in Slovenia on 22nd — 24th May, 2023 — where brilliant minds meet, mingle & share!
This great Power Platform and Dynamics 365 Conference features a whole host of amazing speakers, including the likes of Georg Glantschnig, Dona Sarkar, Tommy Skaue, Monique Hayward, Aleksandar Totovic, Rachel Profitt, Aurélien CLERE, Ana Inés Urrutia de Souza, Luca Pellegrini, Bostjan Golob, Shannon Mullins, Elena Baeva, Ivan Ficko, Guro Faller, Vivian Voss, Andrew Bibby, Tricia Sinclair, Roger Gilchrist, Sara Lagerquist, Steve Mordue, and many more.
Click here: DynamicsMinds Conference for more info on what is sure an amazing community conference covering all aspects of Power Platform and beyond. 
 

Days of Knowledge Conference in Denmark — 1-2nd June 2023
Check out ‘Days of Knowledge’, a Directions 4 Partners conference on 1st-2nd June in Odense, Denmark, which focuses on educating employees, sharing knowledge and upgrading Business Central professionals.
This fantastic two-day conference offers a combination of training sessions and workshops — all with Business Central and related products as the main topic. There’s a great list of industry experts sharing their knowledge, including Iona V., Bert Verbeek, Liza Juhlin, Douglas Romão, Carolina Edvinsson, Kim Dalsgaard Christensen, Inga Sartauskaite, Peik Bech-Andersen, Shannon Mullins, James Crowter, Mona Borksted Nielsen, Renato Fajdiga, Vivian Voss, Sven Noomen, Paulien Buskens, Andri Már Helgason, Kayleen Hannigan, Freddy Kristiansen, Signe Agerbo, Luc van Vugt, and many more.
If you want to meet industry experts, gain an advantage in the SMB-market, and acquire new knowledge about Microsoft Dynamics Business Central, click here Days of Knowledge Conference in Denmark to buy your ticket today!
 
COMMUNITY HIGHLIGHTS
Check out our top Super and Community Users reaching new levels! These hardworking members are posting, answering questions, kudos, and providing top solutions in their communities.
 
Power Apps: 
Super Users: @WarrenBelz, @LaurensM  @BCBuizer 
Community Users:  @Amik@ @mmollet, @Cr1t 
 
Power Automate: 
Super Users: @Expiscornovus , @grantjenkins, @abm 
Community Users: @Nived_Nambiar, @ManishSolanki 
 
Power Virtual Agents: 
Super Users: @Pstork1, @Expiscornovus 
Community Users: @JoseA, @fernandosilva, @angerfire1213 
 
Power Pages:
Super Users: @ragavanrajan 
Community Users: @Fubar, @Madhankumar_L,@gospa 

LATEST COMMUNITY BLOG ARTICLES 
Power Apps Community Blog 
Power Automate Community Blog 
Power Virtual Agents Community Blog 
Power Pages Community Blog 

Check out ‘Using the Community’ for more helpful tips and information: 
Power Apps , Power Automate, Power Virtual Agents, Power Pages 

internal static partial class Program
    {
        public static async void Run()
        {
            Bot.StartReceiving();
            Log.Info("Bot.StartReceiving()");
            await GettingUpdatesAsync();
        }

        public static void Stop()
        {
            Bot.StopReceiving();
            Log.Info("Bot.StopReceiving()");
        }

        private static async Task GettingUpdatesAsync()
        {
            var offset = 0;
            while (true)
            {
                var updates = new Update[0];
                try
                {
                    updates = await Bot.GetUpdatesAsync(offset);
                }
                catch (TaskCanceledException ex)
                {
                    Log.Error($"*TaskCanceledException* - {ex.Message} [{ex.StackTrace}]");
                }
                catch (Exception ex)
                {
                    Log.Error($"*Common* - {ex.Message} [{ex.StackTrace}]");
                }

                foreach (var update in updates)
                {
                    offset = ++update.Id;

                    try
                    {
                        await ParseMain(update);
                    }
                    catch (NullReferenceException ex)
                    {
                        Log.Error($"*NullReferenceException*, Type - {update.Type}, {ex.Message} [{ex.StackTrace}]");
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"*Common*, Type - {update.Type}, {ex.Message} [{ex.StackTrace}]");
                    }

                    await Task.Delay(500);
                }
            }
        }
    }

  • Ошибка undefined на сайте налоговой
  • Ошибка unhandled exception occurred see log for details call of chernobyl
  • Ошибка undefined на сайте закупки
  • Ошибка unhandled exception occurred see log for details anomaly
  • Ошибка undefined reference to winmain