|
|
|
|
|
by smizell
3578 days ago
|
|
Coupling your code to the JSON you receive over the web can lead to some interesting problems. If the system on the other end decides to make some change you are not expecting, it can lead to errors. In JavaScript, a simple thing that helps is to use lodash.get and provide a path to the property you are wanting. lodash.get(someObject, 'path.to.a.property')
If the path isn't there, the lodash.get returns undefined. This is much nicer than getting the error "Cannot read property 'to' of undefined" when "path" isn't there. |
|
https://pypi.python.org/pypi/jsane
>>> j = jsane.loads('{"foo": {"bar": {"baz": ["well", "hello", "there"]}}}')
>>> j.foo.bar.baz[1].r()
u'hello'