4 ms·
When you're consuming JSON that has deep nesting, arrays that contain multiple types, etc. Something that may be two lines of code in a dynamic language could b
by jeremycw 7y ago
When you're consuming JSON that has deep nesting, arrays that contain multiple types, etc. Something that may be two lines of code in a dynamic language could be as much as 100 lines in some static typed languages.
- loxs 7y agoThat's probably the only real case, yes. And still, even this is a non-issue with things like io-ts https://github.com/gcanti/io-ts https://github.com/gcanti/io-ts This is my go to tool (and language) nowadays when I need to do something JSON heavy for a prototype.
- choward 7y agoSure, you could write one line of code to read it in as maps and arrays, but at some point you need to validate your input from the outside world to convert it you your domain objects. Using a dymically typed language doesn't magically make that problem go away.
- FpUser 7y agoDepending on library used it can actually be the same amount of lines. The lines are a bit longer of course. Example auto obj = JSON(text); int age = obj.["persons"][3]["age"];