When the data queried by c# datatable is converted to JSON object, the following error is reported.
Newtonsoft.Json.JsonReaderException: 'Error reading JArray from JsonReader. Path '', line 0, position 0.
The reason for this problem is that the queried data set directly becomes a string, and then an error is reported when it is empty
solution: add judgment
if (jsonStr.Length > 0)
{
JArray jArray = JArray.Parse(jsonStr);
JProperty Data = new JProperty("Data", jArray);
ZzjDataObj.Add(Data);
}
else
{
JArray jArray = new JArray();
JProperty Data = new JProperty("Data", jArray);
ZzjDataObj.Add(Data);
}
Read More:
- Gson Parsing exceptions: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
- Error reading JSON file: json.decoder.JSONDecodeError : Extra data: line 6 column 2 (char 1329)
- MalformedJsonException:Use JsonReader.setLenient(true) to accept malformed JSON at line 3 colum
- There is a problem with newtonsoft.json.dll after adding plastic SCM
- [jQuery] jQuery operates on JSON strings or JSON objects
- 【ipfs-api】npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
- C / C + + error handling (document): unhandled exception: 0xc0000005: access violation while reading location 0x00000000
- The language of C__ FILE__ 、__ LINE__ And line
- Unit Android converts c# class to JSON file and reports an error
- Error of reading character c + +
- json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- Error: unrecognized command line option “-std=c++11”, to solve the problem that ubuntu does not support c++11
- JSON data format net.sf.json .JSONException: A JSONObject text must begin with ‘{‘ at character 1 of Error:(f…
- No code, a solution to the error in the path of reading CSV file by Python: filenotfounderror: [errno 2] no such file or directory: ‘XX. CSV‘
- Python json.dumps () json.dump The difference between ()
- cenos Upgrade g++ gcc(cc1plus: error: unrecognized command line option “-std=c++11”)
- Configuration file for vscode setting.json UI interface or JSON form
- Solution of command line window flashback when visual studio runs C + + program
- c1: Commend line error D8021 :invalid numeric argment ‘/Wno-cpp’
- Unable to read workspace file ‘D:\angular.json‘: Invalid JSON character: “ “ at