On Dec 26, 5:14 pm, sajuptpm <sajup...@gmail.com> wrote: > I am facing an issue while decoding json string using json.loads(jstring). > Its working, if i do json.dumps(eval(jstring)) before json.loads(jstring).
I cannot reproduce your problem using the original string: >>> s = u'{"selected_objects":{"datacenter-2":{"name":"Data !@#$%25^&*()_ {}[]|% 5c%2f.,?><:\\"`Center8(Data !@#$%^&*()_ {}[]|\\\\/.,?><:\ \"`Center8)","type":"Da tacenter","moid":"datacenter-2","ac tual_name":"Data !@#$%25^&*()_ {} []|%5c%2f., ?><:\\"`Center8","server_pools":[{"name":"cluster ~!@#$%25^&*()_ {}|\ \":?><,.%2f ;\'%5c][=-`(cluster ~!@#$%^&*()_ {}|\\":?><,./;\'\\\\][=- `)","type":"ClusterComp uteResource","moid":"domain- c401","actual_name":"cluster ~!@#$ %25^&*()_ {}|\\": ?><,.%2f;\'%5c][=-`","hosts":[{"name":"192.168.1.13","type":"HostSys tem","moid" :"host-27","actual_name":"192.168.1.13"}]}]}}}' >>> json.loads(s) {u'selected_objects': {u'datacenter-2': {u'ac tual_name': u'Data !@#$ %25^&*()_ { }[]|%5c%2f.,?><:"`Center8', u'moid': u'datacenter-2', u'type': u'Datacenter', u' name': u'Data !@#$%25^&*()_ {}[]|%5c%2f.,?><:"`Center8(Data !@#$ %^&*()_ {}[]|\\/ .,?><:"`Center8)', u'server_pools': [{u'hosts': [{u'actual_name': u'192.168.1.13 ', u'moid': u'host-27', u'type': u'HostSys tem', u'name': u'192.168.1.13'}], u'a ctual_name': u'cluster ~!@#$%25^&*()_ {}|":?><,.%2f;\'%5c][=-`', u'moid': u'doma in- c401', u'type': u'ClusterComputeResource', u'name': u'cluster ~!@#$ %25^&*()_ {}|":?><,.%2f;\'%5c][=-`(cluster ~!@#$%^&*()_ {}|":?><,./;\'\\][=- `)'}]}}} >>> Notice the space in the first occurance of the key 'actual_name' (and later in 'HostSys tem') however. Could it be a non-printable character like an EOL that's somehow managed to make its way into your string? Other than that, I'm at a loss as to why you're seeing a difference. Which version of Python are you using? -- http://mail.python.org/mailman/listinfo/python-list