I have the following JSON;
{ "b2c": { "languages": { "de": { "models": { "t300": { "name": "Aveo", "bodyTypes": { "t300-4d-my13": { "trimLevels": { "lt": { "name": "LT", "variants": { "1.2_16V_86_Gas_MT": { "name": "1.2 MT", "price": { "EUR": { "value": 13990, "formatted": "13.990,00 €" } }, "infoFeatures": { "fuel_consumption_extra_urban#consumption": { "name": "Kraftstoffverbrauch außerorts ", "value": "4.6", "formatted": "4,6" }, "top_speed#kilometer_per_hour": { "name": "Höchstgeschwindigkeit", "value": "171", "formatted": "171" } }, "images": null, "documents": null } } } } } } } } } } } }
Values b2c, de, t300, t300-4d-my13, It, etc. are dynamic, but languages, models, bodyTypes, trimLevels, options, inforFeatures, images and documents will remain the same. I need to extract everything in order to access values like languages. ["De"], models. ["T300"]. Name, timeLevels. ["It"], Options and infoFeatures, since these keys [""] are dynamics, so I'm not sure what to say.
I tried,
var jsonSerializer = new JsonSerializer(); dynamic dynamicObject = jsonSerializer.Deserialize(new JsonTextReader(new StringReader(jsonString)));
I looked it too Disable JSON in a dynamic C # object?
and tried
var dynamicObject = Json.Decode(jsonString);
but gets the following error:
An attempt to use the System.Web.Helpers.Json.Decode (System.String) method to access the System.Web.Helpers.Json._serializer field failed.