python格式化输出 json数组

最近在做eBay的对接,所以格式化输出json数组做比对是十分重要的,范例如下

# -*- coding: UTF-8 -*-
import json
data = {'Item': {'ListingType': u'Chinese', 'SubTitle': 'test', 'Title': 'test', 'Country': u'US', 'ConditionID': 1000, 'PaymentMethods': 'PayPal', 'AutoPay': True, 'PayPalEmailAddress': u'dddd', 'Location': u'Afghanistan, Islamic State of, ssss', 'PostalCode': u'10000', 'SellerProfiles': {'SellerPaymentProfile': {'PaymentProfileID': u'5487918000'}, 'SellerReturnProfile': {'ReturnProfileID': u'5596097000'}, 'SellerShippingProfile': {'ShippingProfileID': u'5511516000'}}, 'Quantity': 5, 'Description': u'<![CDATA[\n                  \n          <p>okok</p>\n        \n      ]]>', 'ReturnPolicy': {'ReturnsAcceptedOption': u'ReturnsAccepted', 'RefundOption': u'MoneyBack', 'ShippingCostPaidByOption': u'Days_14'}, 'CategoryMappingAllowed': 'true', 'PrivateListing': True, 'ListingDuration': u'Days_30', 'Currency': u'USD', 'ProductListingDetails': {'UPC': 'Does not Apply', 'BrandMPN': {'MPN': 'Does not Apply', 'Brand': 'Unbranded'}, 'EAN': u'6902538004045'}, 'ItemSpecifics': {'NameValueList': [{'Name': 'Brand', 'Value': 'Unbranded'}, {'Name': 'MPN', 'Value': 'Does not Apply'}]}, 'BestOfferDetails': {'BestOfferEnabled': True}, 'PrimaryCategory': {'CategoryID': u'162922'}, 'ShippingDetails': {'ShippingType': u'Flat', 'ExcludeShipToLocation': [u'AX'], 'ShippingServiceOptions': {'FreeShipping': True, 'ShippingService': False, 'ShippingServiceCost': 23.2}, 'InternationalShippingServiceOption': {'ShippingService': False, 'ShipToLocation': [u'AX']}}}}
print json.dumps(data, sort_keys=True, indent=2)

如此长的data真的是让人头疼

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值