Answer the question
In order to leave comments, you need to log in
How to parse an unusual JSON file in C#?
C# language, JSON format file:
[
[
[1,"Aple",1,"Aple",,1,"s",19],
[2,"Orange",2,"Orange",,0,"bb ",8],
[25,"Raspberry",25,"Raspberry",,1,"-1",1]
]
]
Somehow I parsed json using NewtonSoft - it worked. But I met this file - I don’t understand how to parse it. Knowledge is not enough. Help
Answer the question
In order to leave comments, you need to log in
It's not json.
When there is valid json , go to json2csharp.com , generate classes.
Then with the help of NewtonSoft
Well, further along the fields in the json object
Unfortunately, this is invalid JSON.
If you look at the spec: www.json.org on the right side of the used tokens column, you can see that an empty value should be passed as null.
You have the sequence ,,
The given source is apparently a little smart himself and makes some assumptions when parsing.
Before parsing, you can try to replace such a regular expression:
. For your example, it will do, but you must remember that this is JSON:
Gathering, the idea did not come up how to highlight non-linear elements with a regular expression. This is probably not so simple, given that any element will be between two quotes very often.
As a first workaround for this situation, you can first separate each array by commas and remove or assign null to empty elements ... But this is not easy and will have its limitations.
This is an invalid data format. It just won't be here.
online viewer ( jsonviewer.stack.hu/) recognized - displayed the structure. I don't even know what to add.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question