5 ms·
JSON is an example of plain data. You structure it by nesting maps and lists of items. For example, I work with medical data and here's an example of a structur
by yogthos 8y ago
JSON is an example of plain data. You structure it by nesting maps and lists of items. For example, I work with medical data and here's an example of a structured patient resource in JSON format https://www.hl7.org/fhir/patient-example.json.html https://www.hl7.org/fhir/patient-example.json.html
- supermatt 8y agoif i parse that in javascript it becomes an object. if i want to copy that object it copies the reference to the object and references to the same properties. if i modify it, it then it modifies the original. the best i can do is to create a new object and copy the references over or use it as a prototype, both of which would be considered immutable. nested objects would need to be dealt with in the same way. as i understand, that’s what this lib is doing?
- yogthos 8y agoYou wouldn't parse the data into objects. Instead, the immutable data structure libraries have their own implementation of maps, lists, and so on. These are the data structures you'd be using. And of course, if you're using a language like ClojureScript then it's just how things work out of the box.
- supermatt 8y agoi appreciate what you are saying about these immutable data libs, but i wasn’t aware they parsed and manipulated json directly. it sounds horrendously inneficient to me, but i’ll do some further investigation. thanks for the heads up
- yogthos 8y agoThat's not what I was suggesting these libs do. You receive JSON as text over the wire. Instead of parsing it into native Js objects, it's instead parsed into alternative implementations of immutable data structures. There's nothing inefficient about it.
- supermatt 8y agothanks. i hadn’t looked into the detail of these libs and had made some incorrect assumptions. will definitely look at their usage for a project historically suffering with side effects on the data.