JSON
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
XML
<employees>
<employee>
<firstName>John</firstName>
<lastName>Doe</lastName>
</employee>
<employee>
<firstName>Anna</firstName>
<lastName>Smith</lastName>
</employee>
<employee>
<firstName>Peter</firstName>
<lastName>Jones</lastName>
</employee>
</employees>
Automated using Visual Studio
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
XML
<employees>
<employee>
<firstName>John</firstName>
<lastName>Doe</lastName>
</employee>
<employee>
<firstName>Anna</firstName>
<lastName>Smith</lastName>
</employee>
<employee>
<firstName>Peter</firstName>
<lastName>Jones</lastName>
</employee>
</employees>
Automated using Visual Studio
This approach uses Visual Studio to generate a class just by copying and pasting the JSON or XML string.
The following is the procedure to generate the class:
The following is the procedure to generate the class:
- Copy JSON or XML string
JSON
XML - Go to Edit > Paste Sepcial > Paste JSON As Classes or Paste XML As Classes.
Visual Studio generates a class structure for the developer as in the following:
The following is an example of the class structure created by copying and pasting a JSON string.
The following is an example of the class structure created by copying and pasting a JSON string.
public class EmployeeList {
public Employee[] employees {
get;
set;
}
}
public class Employee {
public string firstName {
get;
set;
}
public string lastName {
get;
set;
}
}
No comments:
Post a Comment