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

Update api.md #287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ You can set the filter like this:
```
Expression e = new Parser(reader)
.withObjectFilter(filter)
.parse();
.compile();
```

The filter can be either a string containing JSLT. The JSLT expression
needs to return `true` for the object values that should be included.
So to get the default behaviour you would set the filter to:

```
. == null or . == {} or . == []
. == null or . == {} or . == [] or not(.) == false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addition is not correct. As you can see here it really is null, {}, and [] that are the omitted values.

The suggested change would, for example, filter out true, and 5, and so on.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@larsga Here we have two different implementations:

  1. Default implementation: NodeUtils.isValue(value); - here
  2. Custom implementation: NodeUtils.isTrue(jslt.apply(value)); - here

NodeUtils.isValue(value) != NodeUtils.isTrue(value)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's true, but the example expression says how to reproduce the default behaviour, which is your number 1.

```

If you simply want no object keys to ever be omitted, set it to:
Expand Down