adriank / ObjectPath

The agile query language for semi-structured data
http://objectpath.org
MIT License
380 stars 93 forks source link

Dynamic concatenation of arrays #76

Closed tyjak closed 2 years ago

tyjak commented 5 years ago

Given this data:

{
     "foo": [
          {"bar": [1, 2, 3]},
          {"bar": [4, 5, 6]}
    ]
}

Is there a way to concatenate "bar" values in order to obtain a single list like this

[1,2,3,4,5,6]

Obviously this query returns a list of lists

tree.execute('$.foo[bar]')

Thanks

adriank commented 5 years ago

It's probably impossible. You could add chain function to the ObjectPath. I'll accept the PR.

Greetings, Adrian Kalbarczyk

http://kalbarczyk.co

On Fri, Nov 23, 2018 at 11:51 AM tyjak notifications@github.com wrote:

Given this data:

{ "foo": [ {"bar": [1, 2, 3]}, {"bar": [4, 5, 6]} ] }

Is there a way to concatenate "bar" values in order to obtain a single list like this

[1,2,3,4,5,6]

Obviously this query returns a list of lists

tree.execute('$.foo[bar]')

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adriank/ObjectPath/issues/76, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKyclycda1waFYVxl7XVcaXAiKkHD6Fks5ux9NLgaJpZM4YwdE1 .