Trying to Deserialize a Json String using Deserialize Json activity

I am using Newtonsoft’s web activities. Specifically the Deserialize Json Activity.

I am passing in a json string that was serialized previously by some process. This is the Json Data:
{“lineItem”:{“1”:{“myMaterial”:“1111”,“customerMaterial”:“90139”,“orderQty”:“1951”,“unitOfMeasure”:“M”}},“salesOrg”:“10”,“distributionChannel”:“1”,“division”:“1”,“orderType”:“50Q1”,“shipTo”:“8888888”,“customerName”:“ACustomer”,“requestedDeliveryDate”:“01/20/2020”,“poType”:“ZZZ1”,“poNumber”:“1111111”}

Note the data has been changed for confidentiality.

I am passing this string into a custom process I built and published to my company’s orchestrator.

My problem is that the serialization of the json string to a json object fails.

Here is my exception message:
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.
Note: It says I am trying to convert to a JToken but my type arguments are JObject

So I understand what the error is saying yet I do not see how this is true when I see that the Json String is in the proper configuration to be serialized. I even tested it on the machine that I wrote the code in. However, when I pass it as a parameter from a separate process it causes this exception. Any idea where to start for this issue?

Let me know if you need any more information.

try this instead

where result is Dictionary<String,Object>

then you assign

Newtonsoft.Json.JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(text)

to result

where text = your input text i.e.
{“lineItem”:{“1”:{“myMaterial”:“1111”,“customerMaterial”:“90139”,“orderQty”:“1951”,“unitOfMeasure”:“M”}},“salesOrg”:“10”,“distributionChannel”:“1”,“division”:“1”,“orderType”:“50Q1”,“shipTo”:“8888888”,“customerName”:“ACustomer”,“requestedDeliveryDate”:“01/20/2020”,“poType”:“ZZZ1”,“poNumber”:“1111111”}

@cody.vollrath
give a try on:

yourParsedJSON is the output of Serialize JSON Acitvity

Newtonsoft.Json.JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(yourParsedJSON("lineItem")("1").toString)

to get

{“myMaterial”:“1111”,“customerMaterial”:“90139”,“orderQty”:“1951”,“unitOfMeasure”:“M”}},“salesOrg”:“10”,“distributionChannel”:“1”,“division”:“1”,“orderType”:“50Q1”,“shipTo”:“8888888”,“customerName”:“ACustomer”,“requestedDeliveryDate”:“01/20/2020”,“poType”:“ZZZ1”,“poNumber”:“1111111”}

as a JObject give a try on
yourParsedJSON("lineItem")("1").Value(Of JObject)

I used a variant of your solution instead of conversion to dictionary I used JObject as I intended originally and this worked perfectly. Would you hapen to understand why it is better to use the Newtonsoft library using VB syntax rather than a direct activity? Not sure why it would not work for the official activity.
Anyways, Thank you very much for your solution. Saved me loads of time.

Thank you as well!

No problem, good luck!

Would you hapen to understand why it is better to use the Newtonsoft library using VB syntax rather than a direct activity? Not sure why it would not work for the official activity.

i think its because I sometimes have issues with importing packages so its better if i can import one less package if i directly use Newtonsoft library with VB syntax