Comments (3)
In your case, gjson is simply treating ~false
as all values that are not true-ish.
I agree that this is probably not desired.
Rather, we likely want to more explicit, where all true-ish values are true, and all false-ish are false.
I made some updates moments ago to the syntax that addresses the ~false
issue.
Now vals.#(b==~false)#.a
returns [3,4,5,9,10,11]
.
I also added two more tilde types:
~null Converts null and non-existent values to true
~* Converts any existing value to true
Is there a way to get the fields, for which the data is either null or missing?
Yes, using ~null
or ~*
:
vals.#(b==~null)#.a => [10,11]
vals.#(b!=~null)#.a => [1,2,3,4,5,6,7,8,9]
vals.#(b==~*)#.a => [1,2,3,4,5,6,7,8,9,10]
vals.#(b!=~*)#.a => [11]
from gjson.
Great! Just tried and it works like a charm! ~*
is a handy addition too. Thank you!
from gjson.
No problem. I'm happy to hear it's working. :)
from gjson.
Related Issues (20)
- The fromstr modifier does not support special strings, such as ! HOT 9
- import "github.com/tidwall/gjson" is a program, not an importable package HOT 2
- Query for node that doesn't have specified field HOT 1
- Iterating only first N items in an array HOT 2
- pretty modifiers are not working as expected HOT 2
- I need a set function to modify json string HOT 1
- What is the difference between raw and str HOT 1
- Querying nested optional array HOT 2
- Same problem as #259
- Accessing key with periods in it HOT 6
- How to use gjson's capabilities to convert json strings into objects HOT 1
- Flatten/Expand Array HOT 2
- join flat array to comma separated string HOT 2
- help with a query to get all paths in a nested json HOT 2
- forEach fo current json string HOT 4
- How to get next value under ForEach function HOT 2
- How to pick up specific values from array of objects into target array of objects? HOT 2
- How to apply multipaths to all elements of an array HOT 1
- Query based on content
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gjson.