The custom_json inconsistent format increase the complexity

The custom_json inconsistent format increase the complexity

I have been wanting to make a few tools that require pre-processing the custom_json fields. however the script gets exceptions from time to time due to the inconsistent format of the custom_json.

For example, sometimes, I see this format:

1
{'required_auths': [], 'id': 'follow', 'required_posting_auths': ['steemit'], 'json': '["follow", {"follower":"steemit","following":"steem","what":["posts"]}]'}

And sometimes this:

1
{'required_auths': [], 'id': 'follow', 'required_posting_auths': ['steemit'], 'json': '{"follower":"steemit","following":"steem","what":["posts"]}'}

I assume that it is up to the front-end to interpret if the format is correct. At this point, the steem blockchain is just a public immutable database, and it has no idea what the JSON data means.

And also, this is worse:

1
{'required_auths': [], 'required_posting_auths': ['jpphoto'], 'id': 'follow', 'json': '"[\\"reblog\\",{\\"account\\":\\"jpphoto\\",\\"author\\":\\"photovisions\\",\\"permlink\\":\\"travel-norway-27-autumn-in-sylan-mountains-snow-and-reindeers\\"}]"'}

First JSON decode gives a valid JSON string which needs to be decoded. It might be obvious for human to understand the data, but for computer programs, you would need to handle all these cases, at least, you would need to realise the incorrect format, discard it, and move on - instead of throwing exception and halt.

Life is hard.


Every little helps! I hope this helps!

Steem On!~

Reposted to Blog

If you like my work, please consider voting for me, thanks!
https://steemit.com/~witnesses type in justyy and click VOTE



Alternatively, you could proxy to me if you are too lazy to vote!

Also: you can vote me at the tool I made: https://steemyy.com/witness-voting/?witness=justyy

Visit me at: https://steemyy.com


This page is synchronized from the post: ‘The custom_json inconsistent format increase the complexity’

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×