i receiving following string via api in python:
{"id":13021,"buys":{"quantity":3494,"unit_price":257},"sells":{"quantity":3187,"unit_price":433}} i can reliably isolate "id" field via .find, "buys" , "sells" entries "unit_price" harder recover since don't share unique identifiers. best bet parse whole thing regular expressions, or python offer more straightforward solution access required substrings?
your input data json. using regexp in case overkill. convert dict , work like
import json instr = '{"id":13021,"buys":{"quantity":3494,"unit_price":257},"sells":{"quantity":3187,"unit_price":433}}' injs = json.loads(instr) injs["buys"] out[62]: {'quantity': 3494, 'unit_price': 257}
Comments
Post a Comment