You are viewing a single comment's thread from:

RE: Python to Convert String Representation of JSON (On Reblogs) to Dictionary

in #python6 years ago (edited)

I think you should be able to achieve the same withjson.loads()
(untested code)

import json
[...]
for h in a.get_account_history(-1,10000, filter_by=["custom_json"]):
  jsdata = json.loads(h['json'])
  if jsdata[0] == "reblog":
    [...]

The raw json could potentially contain spaces between strings and brackets etc, which your approach might miss.

Sort:  

I didn't take that into account.

It seems to work for my purposes at the moment but I realize I wouldn't work for anything other than reblogs the way it is written (I may be able to split on the first comma but still not sure if there would be a situation such as you described that would screw it all up).

The method looks like to could be used for for a universal conversion so I'll get it tested and let you know!

Thanks, @crokkon!

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.032
BTC 58576.55
ETH 2982.45
USDT 1.00
SBD 3.71