Comments (9)
@NDuggan So sorry, was bogged down with a ton of stuff! This is next on my todo list now though. :)
from jsonpath.
What... even is that? :D
from jsonpath.
Oh it's a regex match against an element. Or at least something like a "%http%" in SQL and the likes. Hmmmmmm.....
from jsonpath.
The parsing kind of completely falls apart on this one. :/ Uh.
from jsonpath.
Alright, so I might be able to handle this gracefully, I think. Your pattern in that case would be something like /http/.match(@whatever
. I'm using match
to conform to ruby's regex match.
from jsonpath.
I wonder if this syntax is a standard that should be adopted? there is no standard reference other than the original https://goessner.net/articles/JsonPath/ and even there makes no mention of filters supporting regex
Looking at the Java implementation to support regex filter is also different: https://github.com/json-path/JsonPath
from jsonpath.
Yah, that's why I was reluctant to do it. It sort of messes things up a bit. :/ But I might implement it at one point anyways. :)
from jsonpath.
@khairihafsham It just dawned on my that I'm supporting regex in a query.
You could try ?(@name =~ /http[s]?/)
or something like that.
from jsonpath.
@khairihafsham Yep. This actually works:
def test_regex_2
json = '
{
"ports": {
"extraports": {
"count": "996",
"state": "filtered",
"extrareasons": {
"count": "996",
"reason": "no-responses"
}
},
"port": [
{
"portid": "80",
"protocol": "tcp",
"service": {
"conf": "3",
"method": "table",
"name": "http"
},
"state": {
"reason": "syn-ack",
"reason_ttl": "44",
"state": "open"
}
},
{
"portid": "443",
"protocol": "tcp",
"service": {
"conf": "3",
"method": "table",
"name": "https"
},
"state": {
"reason": "syn-ack",
"reason_ttl": "44",
"state": "open"
}
},
{
"portid": "2222",
"protocol": "tcp",
"service": {
"conf": "3",
"method": "table",
"name": "EtherNetIP-1"
},
"state": {
"reason": "syn-ack",
"reason_ttl": "45",
"state": "open"
}
},
{
"portid": "3128",
"protocol": "tcp",
"service": {
"conf": "3",
"method": "table",
"name": "squid-http"
},
"state": {
"reason": "syn-ack",
"reason_ttl": "44",
"state": "open"
}
}
]
}
}
'.to_json
assert_equal [{"conf"=>"3", "method"=>"table", "name"=>"http"}, {"conf"=>"3", "method"=>"table", "name"=>"https"}, {"conf"=>"3", "method"=>"table", "name"=>"squid-http"}], JsonPath.on(json, "$..[?(@.name =~ /http[s]?/)]")
end
from jsonpath.
Related Issues (20)
- Results do not match other implementations HOT 5
- Feature: Pass accessor path to gsub HOT 6
- Getting TypeError if one of the nodes in json has name "hash" HOT 24
- Does not match properly on double equals `==` expression when field name has a dot in it HOT 10
- TypeError: 0 is not a symbol nor a string exception HOT 1
- Requires tag for new release HOT 6
- Results do not match other implementations (Part 2)
- JSONPath comparison and standardisation HOT 3
- Please don't depend on to_regexp HOT 5
- Generate jsonpath list from json HOT 1
- Not possible to access values of numeric keys HOT 3
- nesting of 101 is too deep HOT 1
- Impossible to filter elements of an array with unknown name HOT 2
- Compound queries that test boolean values do not work HOT 4
- Compound queries do not evaluate false expressions properly HOT 1
- Not equals (!=) operator broken unless preceded by space HOT 2
- Negating the filter expression using ! is not working HOT 1
- Jsonpath with $ keyname not working HOT 4
- `symbolize_keys` option doesn't work as the README says HOT 1
- UTF8 member names not supported
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 jsonpath.