0

I have a json file, large one. It has a structure like this:

[{"property":{"propertyID":85630,"name":"Curry Junction"}}]JSON_F52E2B61-18A1-11d1-B105-00805F49916B[{"property":{"propertyID":85630,"name":"Curry Junction"}}]

Now, I am trying to parse it or even split it. This json file is full of errors which is why I had to introduce custom convertors to help me. For example "prop\r\nerty" is like this and there are some spaces inside values. I was able to clean the file but problem is I am not able to find a way how to read second array with Newtonsoft. Right now I am hitting the error: >"Additional text encountered after finished reading JSON content: J. Path ''">

Is there a way to either deserialize this json file into proper object that I created? Can it be assumed that JSON_F52E2B61-18A1-11d1-B105-00805F49916B is some custom token, random one that can be ignored with code?

Here is the sample how I am doing deserialization:

using (StreamReader r = new StreamReader(fileName))
        {
            string json = r.ReadToEnd();
            return JsonConvert.DeserializeObject<Property[]>(Regex.Replace(json, "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"), new JsonSerializerSettings
            {
                Error = HandleDeserializationError,
                Formatting = Formatting.None,
                Converters = new List<JsonConverter> { new PropertyConverter() }
            });
        }
  • There was nice looking duplicate, but that one should do... If not enough start with FM - https://www.newtonsoft.com/json/help/html/ReadMultipleContentWithJsonReader.htm and [edit] post to clarify why it did not work. – Alexei Levenkov Apr 07 '20 at 21:22
  • @AlexeiLevenkov First error I am experiencing is: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'SmartModels.Property' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. – Miloš Đošović Apr 07 '20 at 21:38
  • @AlexeiLevenkov Also, this question: https://stackoverflow.com/questions/16765877/additional-text-encountered-after-finished-reading-json-content is giving me same error as I pointed, Additional text encountered after finished reading JSON content. – Miloš Đošović Apr 07 '20 at 21:45
  • [Edit] your question (or ask new one) with simple JSON and [MCVE] that demonstrates the problem with somthing like "I looked at {link to SO question} and it should have worked but I'm getting ...". – Alexei Levenkov Apr 07 '20 at 22:00

0 Answers0