Remove Backslash from JSON string? Remove Backslash from JSON string? json json

Remove Backslash from JSON string?


I am not very sure your is a function or not. Anyways, the response you receive is having the literal character ' and you need to replace it with ".

Here is the working code:

import urllib2,jsonheaders = {'User-Agent': 'Mozilla/5.0'}req = urllib2.Request("http://spatialreference.org/ref/esri/nad-1983-stateplane-california-vi-fips-0406-feet/json/", None, headers)response = urllib2.urlopen(req)response_read = response.read()epsg_json = json.loads(response_read.replace("\'", '"'))epsg_code = epsg_json['properties']['code']print(epsg_code)

Hope this helps.


you need to first use dumps then loads

json_data = json.dumps(response_read)json_without_slash = json.loads(json_data)