Skip to content
New issue

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

Indexing into null return null option #75

Closed
sixinli opened this issue Mar 25, 2015 · 2 comments
Closed

Indexing into null return null option #75

sixinli opened this issue Mar 25, 2015 · 2 comments
Labels

Comments

@sixinli
Copy link

sixinli commented Mar 25, 2015

Hi I am using jsonPath and hit an edge case in which i can't extract things in a persisting order:

{
"context" : [
{ "level1" : { "value1": 1, "value2": { "inner": 2 } } },
{ "level1" : { "value1": 3 } },
{ "level1" : { "value1": 4, "value2": { "inner": 5 } } }
]
}

"$.context.level1.[*].value2" with DEFAULT_PATH_LEAF_TO_NULL will return
[
{ "inner": 2 },
null,
{ "inner": 5}
]

ideally i want to extract [ 2, null, 5 ], and there's no way to get this now because
"$.context.level1.[ * ].value2.[ * ].inner" will return [ 2, 5 ]
*note that if "value2" for "level1" is {} instead this will [ 2, null, 5 ], but it's not possible for me to get that for now

I am wondering if it's possible/reasonable to support indexing into null return null as a configuration option?

Thanks!

@kallestenflo
Copy link
Contributor

$.context[*].level1.value2

with Option.DEFAULT_PATH_LEAF_TO_NULL is probably your best shot as I don't see this as a common use case.

@kallestenflo
Copy link
Contributor

I will not implement this since it's to much of a corner case and not supported by other implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants