Hey,
I got two JSON objects and would like to merge them together into a single one. Are there any helper methods that I am not seeing or do I just go ahead and do this manually?
Thanks for any pointers!
–Alex
Hey,
I got two JSON objects and would like to merge them together into a single one. Are there any helper methods that I am not seeing or do I just go ahead and do this manually?
Thanks for any pointers!
–Alex
Do you want to …
dig
methods might help to have a in flight fallback of any key.JSON::Any
value? => yeah, manually I think.a.to_h.merge(b.to_h)
You could use JSON::OnSteroids.
Basically it’s mutable JSON structure, allowing you to transform it. The documentation is still in progress but there’s a merge method built-in.
new_json = json1.on_steroids.merge!(json2)
new_json.to_json