반응형

소스코드

import json
from collections import OrderedDict

json_data = OrderedDict()

json_data['success'] = 'true'
json_data['result'] = 'true'
json_data['image_count'] = 3

image1 = OrderedDict()
image1['title'] = '1111111'
image1['desc'] = 'dddddd'

image2 = OrderedDict()
image2['title'] = '222222'
image2['desc'] = 'fffffff'

image_list = []
image_list.append(image1)
image_list.append(image2)

json_data['image_list'] = image_list

print(json.dumps(json_data , ensure_ascii=False , indent='\t'))

 

결과 Json

{
        "success": "true",
        "result": "true",
        "image_count": 3,
        "image_list": [
                {
                        "title": "1111111",
                        "desc": "dddddd"
                },
                {
                        "title": "222222",
                        "desc": "fffffff"
                }
        ]
}
반응형

+ Recent posts