-1

I'm new to JSON Serialization and Deserialization, so I've been googling alot about this topic, but I couldn't come to figuring out my problem. My main goal is to deserialize the JSON string and write a SQL insert statement from it. Being new to this topic, I'm not sure what deserializing a JSON string returns, but I read somewhere that it returns an object array? For example how would I deserialize this JSON string:

[{"First_Name":"Bob","Last_Name":"Smith","Job":"Engineer"},
{"First_Name":"Jane","Last_Name":"Doe","Job":"Scientist"}]

and deserialize it into a SQL statement?

btayzer
  • 1
  • 3

1 Answers1

3

Using Json.Net

var users = JsonConvert.DeserializeObject<List<User>>(json);

Using JavaScriptSerializer

var users = new JavaScriptSerializer().Deserialize<List<User>>(json);

public class User
{
    public string First_Name { get; set; }
    public string Last_Name { get; set; }
    public string Job { get; set; }
}
L.B
  • 114,136
  • 19
  • 178
  • 224