We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assume, I've this JSON
[ { "key1": "value1", "key2": "value2", "subs": [ { "key3": "value3", "key4": "value4", "subs": [ { "key5": "value5", "key6": "value6" } ] }, { "key7": "value7", "key8": "value8" }, { "key9": "value9", "key10": "value10" } ] } ]
JSON can have arbitrary nesting, but has static field "subs" for nested objects.
I need to get all objects (incl nested):
[ { "key1": "value1", "key2": "value2" }, { "key3": "value3", "key4": "value4" }, { "key5": "value5", "key6": "value6" }, { "key7": "value7", "key8": "value8" }, { "key9": "value9", "key10": "value10" } ]
How can i achieve this?
The text was updated successfully, but these errors were encountered:
@packman80 I think this should work:
map extract_subs { let collapsed_subs = if this.subs != null { this.subs.fold({}, item -> item.tally.merge(item.value.apply("extract_subs"))) } else { {} } root = this.without("subs").merge($collapsed_subs) } root = this.fold({}, item -> item.tally.merge(item.value.apply("extract_subs")))
Sorry, something went wrong.
It produces one object. Not exactly what i need (array of objects). I will try to improve it for my task. Thanks anyway.
I have a mapping that does the job as requested, but it's a bit hackish:
map do_obj { let innerObjs = this.subs.map_each(v -> v.apply("do_obj")).or([]) root = [this.without("subs")].merge($innerObjs).flatten() } root = this.map_each(v -> v.apply("do_obj")).flatten()
Besides the two calls to flatten(), which I think should be avoidable somehow, that should do the trick.
flatten()
No branches or pull requests
Assume, I've this JSON
JSON can have arbitrary nesting, but has static field "subs" for nested objects.
I need to get all objects (incl nested):
How can i achieve this?
The text was updated successfully, but these errors were encountered: