First, Python custom class object JSON string of steps [1]
1. Use JSON or Simplejson to do it;
2. Define the conversion function:
3. Defining classes
4. Generating objects
5.dumps execution, introducing conversion functions
Specifically, if it is a python built-in object, such as a list, FLOAT,STR, etc., no conversion function is required. Otherwise, the JSON module cannot be processed by default and throws an exception: TypeError xx is not JSON serializable
My Code:
Second, generate a JSON string containing the list of objects in Python and write it to a file with the following code:
Third, the JSON file is parsed on the C # side:
1, first define the product class, the code is as follows:
2. Use NewtonSoft.JSon.dll to directly convert the JSon file to a list of objects. Newtonsoft.Json.dll must first be introduced into the project, the code is as follows:
Iv. Reference Documents:
"1" Python custom class object JSON string method, http://blog.csdn.net/superch0054/article/details/12065727
"2" Newtonsoft.json uses C # sequence number Json, deserializes objects, http://blog.sina.com.cn/s/blog_4d38a3b001019pzi.html
"Original" intermediate file for object conversion using JSON as Python and C # mixed programming