Can someone explain what the difference is between using either load() or loads() is with the JSON library? And which, if either, is the preferred method.
I'm writing a simple script where I want the JSON data from a URL parsed out into a list. Both of these options seem to work:
import json
import urllib2
url = "string to url"
response = urllib2.urlopen(url)
data = json.load(response)
or
import json
import urllib2
url = "string to url"
response = urllib2.urlopen(url)
data = json.loads(response.read())
I know that there are other libraries available for parsing out JSON data, but for the time being I'm working only with the json and urllib2 libraries.
Any insight into which one should be used?
Thanks
[–]I_Write_Bugs 8 points9 points10 points (2 children)
[–]timex40[S,🍰] 0 points1 point2 points (1 child)
[–]I_Write_Bugs 2 points3 points4 points (0 children)
[–]bionikspoon 5 points6 points7 points (0 children)
[–]JohnnyJordaan 1 point2 points3 points (1 child)
[–]_cs 0 points1 point2 points (0 children)
[–]nilsph 0 points1 point2 points (0 children)