-1

i need deserialize this json (https://mtgjson.com/json/AllCards.json), but have property name dynamic, y try with json.net with dynamic object in c#. help please.

  • Can we have a look at your code? Just the block where you do your deserialization. – Ram Kumaran Mar 02 '19 at 21:03
  • var listas = new List(); string cartasJson = System.IO.File.ReadAllText(@"C:\AllCards.json"); var cartas = JsonConvert.DeserializeObject(cartasJson); foreach (var item in cartas) { listas.Add(item.name); } Whe i try to get name property, the program crash because dont find the "name" property – pikipichiummm Mar 03 '19 at 04:39

1 Answers1

0

Take a look at this SO answer. You can use something like the following:

var json = System.IO.File.ReadAllText("path/to/dataFile.json"); // read JSON string data
dynamic data = Json.Decode(json); // parse JSON string 

You will need to get Json.Decode from the System.Web.Helpers assembly, which I think should be available in the MVC 5 Nuget package.

Bondolin
  • 2,793
  • 7
  • 34
  • 62