News for hackers. Stuff that matters.
Re:JSON Feed by dangerlibrary on Wednesday May 17, 2017 @02:34PM (#14361420)
This is really only true in dynamically typed languages. From personal experience: parsing json in Java or Go without just treating everything as a bag of Object or an interface{} requires a ton of menial boilerplate work.

Super nice in python/ruby/javascript, though.

Re:JSON Feed by kitsunesoba on Wednesday May 17, 2017 @02:46PM (#14361561)
Swift 4 will have JSON encoding/decoding built in, and I wouldn't be surprised to see such a feature spring up in other modern languages too. Once that boilerplate is eliminated, json is a pretty decent solution.

https://www.hackingwithswift.com/swift4

Re:JSON Feed by moduspol on Wednesday May 17, 2017 @02:50PM (#14361603)
I am very stoked for this.
Re:JSON Feed by tveita on Wednesday May 17, 2017 @03:41PM (#14362118)
> parsing json in Java or Go without just treating everything as a bag of Object or an interface{} requires a ton of menial boilerplate work.

From my experience in Java it is pretty simple using a library like Jackson. You define the types you expect to read, maybe add some annotations, and then it's one function call to deserialize. IIRC Go has something similar in its json library.

Re:JSON Feed by cdelsolar on Wednesday May 17, 2017 @03:48PM (#14362182)
Yes, it's arguably nicer in Go, because you specify exactly what types and field names you expect, and then it's just a simple json.Unmarshal
Re:JSON Feed by moduspol on Wednesday May 17, 2017 @02:46PM (#14361557)
Sure--it's kind of a pain in Swift, too.

Wouldn't it just be worse with XML, though? I get that people don't realistically parse it themselves and libraries are smart enough to use schemas to deserialize, but there's nothing inherent about JSON that makes it unable to conform to a schema or be parsable by libraries into native strongly-typed objects the same way.

Re:JSON Feed by mstade on Wednesday May 17, 2017 @02:57PM (#14361663)
Except JSON doesn't have semantics to describe schemas, only arrays, objects, strings, numbers and null. You can say "but this key is special" but then it's not JSON anymore. And if you're ok with that, may as well just use JSON-LD or some other JSON-like format.
Re:JSON Feed by zokier on Wednesday May 17, 2017 @05:36PM (#14363023)
Idk, I think JSON parsing is pretty ergonomic in Rust, definitely nicer than your typical XML DOM.