Doing a simple JObject.parse(inJson) from Newtonsoft.json gives me the error Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JObject

Hi @Shubham_Mawar

The error occurs because size is an array, not an object. To fix it, parse the JSON as JObject and access size as JArray:

Dim jsonObject As JObject = JObject.Parse(inJson)
Dim sizeArray As JArray = jsonObject("img")("size")
Dim width As Integer = sizeArray(0)
Dim height As Integer = sizeArray(1)

Avoid casting JArray to JObject.

If you found helpful, feel free to tick as a solution.
Happy Automation