I have a script that runs a JSON Deserialization which runs perfectly. When I try to call this script from another script I keep getting an error about not being able to deserialize the current JSON object.
Now I have had issues similar to this before where the project.json files didn’t have the same dependencies but I checked that and they’re all fine.
This exact same process also ran last month with the exact same structured json strings with no issue. So I’m not sure what could have changed in a month that now causes deserialization errors when running this module from a different script. Everything is exactly the same except for the data, but the structure of the json is exactly the same as I compared a line from last month to this current feed in a JSON editor and they lined up exactly the same.
You are getting everything exactly the same except for the data - Meaning you are not getting the correct data to Desterilize the JSON String into JSON Object.
There is something extra or need something else in your Script that causes this exception.
The error message I get is this:
Deserialize JSON: Cannot deserialize the current JSON object (e.g. {“name”:“value”}) into type ‘Newtonsoft.Json.Linq.JToken’ because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path ‘Line_no1.REVCODE’, line 1, position 357.
And I’m sorry about the terminology, I know it can be confusing. Basically I have a file that will log into a system and once it gets there it will run the assigned ‘Script’. The ‘Script’ can run on it’s own but it has to be logged into the system. So I can manually log into the system and run the Script and I don’t get this error. Everything works just fine. I only get the error when it’s being called from another process.
#4 here did the trick. The Process that calls the ‘Script’ had “Newtonsoft.Json”: “[13.0.1]” in it’s project.json. But the script could deserialize properly without that line in it’s project.json. So I took that line out of the process that calls our script and it was able to make it through. Thank you!