I just want to ask something about json and python.
If I'm correct, loading a StringIO to json would result to it having a u'
.
for example, in the json library:
>>> from StringIO import StringIO
>>> io = StringIO('["streaming API"]')
>>> json.load(io)
results to
[u'streaming API']
so how do I parse this data? in order for me to sort a data that looks like this? I have this data I want to parse.
{u'brix': {u'Nov 29, 2017 11:20:15 PM': {u'Checklist': {u'Coffee tray with 3 coffee sticks, 3 creamer, 3 white sugar, 3 brown sugar, 1 equal or sweetener, 3 lipton tea, 2 mineral water, 3 cocktail napkin ?': u'No', u'Luggage bench fabric top is clean': u'No', u'1 facial tissue in a tissue box': u'No', u'Towel Reminder': u'No', u'1 pringles, 1 cashew nut, 1 cup noodles (placed in the coffee tray on the writing desk)?': u'No',
After reading a bit about json I found out that this may be a StringIO instead of a json. It was silly that I tried to do json.loads with it when I it's already loaded. All I want is to sort all of these data so it appears properly on web.
How do i properly do this? Do i decode these to json first so it becomes something like
{
"maps":[
{"id":"blabla","iscategorical":"0"},
{"id":"blabla","iscategorical":"0"}
],
"masks":
{"id":"valore"},
"om_points":"value",
"parameters":
{"id":"valore"}
}
Then get a value from that using this?
data["maps"][0]["id"] # will return 'blabla'
data["masks"]["id"] # will return 'valore'
data["om_points"] # will return 'value'
Anyway, I'm confused of what I should do, I tried pretty much everything, these example came from other questions .
Here's a bit of my code:
result1 = firebase.get('/Rooms/Room1/2017-11-29/Inspection/Scan-in/Inspector/', None)
result2 = firebase.get('/Rooms/Room1/2017-11-29/Inspection/Scan-out/Inspector/', None)
print result1["brix"]
Firebase is supposed to return a json file. lol but it doesn't work on mine.
Thankyou very much to those who will clear it out to me.