Jump to content
UBot Underground

[FREE plugin] JsonPath Parser Plugin


Recommended Posts

  • 4 weeks later...

Thanks for this great plugin Aymen.  Can anyone explain how I can use this plugin to handle null values in JSON?  For example, here is a list of 10 fields that I am trying to parse, however, when I add these items to a list, I don't get 10 results if any of the fields are null.

 

                    set(#f01_Address,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.Address"),"Global")
                    set(#f02_CommRefCode,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.CommRefCode"),"Global")
                    set(#f03_Comments,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.Comments"),"Global")
                    set(#f04_DA,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.DA"),"Global")
                    set(#f05_Enhanced_Area,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.Enhanced.Area"),"Global")
                    set(#f06_Enhanced_Bedrooms,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.Enhanced.Bedrooms"),"Global")
                    set(#f07_Enhanced_CondoType,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.Enhanced.CondoType"),"Global")
                    set(#f08_Enhanced_Depth,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.Enhanced.Depth"),"Global")
                    set(#f09_Enhanced_DrivewayType,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.Enhanced.DrivewayType"),"Global")
                    set(#f10_Enhanced_Fireplaces,$plugin function("JSONpath.dll", "$JSONpath parser", #json, "$.Enhanced.Fireplaces"),"Global")

 

                     add list to list(%EAIDetailRow,$list from text("{#f01_Address},{#f02_CommRefCode},{#f03_Comments},{#f04_DA},{#f05_Enhanced_Area},{#f06_Enhanced_Bedrooms},{#f07_Enhanced_CondoType},{#f08_Enhanced_Depth},{#f09_Enhanced_DrivewayType},{#f10_Enhanced_Fireplaces},",","),"Don\'t Delete","Global")

 

What should I be doing to handle for null values in my JSON?  I suppose one way to do this would be to test the length of each variable, and if it has zero length, then substitute that for "".  Any other ideas for how to do this?  Thanks.

 

UPDATE:  I solved this issue by replacing the null with a space in my JSON using this command:  set(#json,$replace(#json,"null","\" \""),"Global")

Now I am getting the correct number of fields in my list, even if there are nulls.  

Edited by APTS
Link to post
Share on other sites
  • 3 months later...
  • 5 months later...

Filtering doesn't seem to be working . These expression won't bring up nothing

set(#BookswithISBNnumber,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[?(@.isbn)]"),"Global")
set(#CheaperThan10Books,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[?(@.price<10)]"),"Global")

set(#LastBook,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[(@.length-1)]"),"Global")

set(#Priceis899,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[?(@.price==8.99)]"),"Global")

set(#Morethan10price,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[?(@.price>10)]"),"Global")

The expressions used above seem to be working in http://jsonpath.com/?

 

all the code below

set(#testdata,"\{ \"store\": \{
    \"book\": [ 
      \{ \"category\": \"reference\",
        \"author\": \"Nigel Rees\",
        \"title\": \"Sayings of the Century\",
        \"price\": 8.95
      \},
      \{ \"category\": \"fiction\",
        \"author\": \"Evelyn Waugh\",
        \"title\": \"Sword of Honour\",
        \"price\": 12.99
      \},
      \{ \"category\": \"fiction\",
        \"author\": \"Herman Melville\",
        \"title\": \"Moby Dick\",
        \"isbn\": \"0-553-21311-3\",
        \"price\": 8.99
      \},
      \{ \"category\": \"fiction\",
        \"author\": \"J. R. R. Tolkien\",
        \"title\": \"The Lord of the Rings\",
        \"isbn\": \"0-395-19395-8\",
        \"price\": 22.99
      \}
    ],
    \"bicycle\": \{
      \"color\": \"red\",
      \"price\": 19.95
    \}
  \}
\}","Global")
set(#AuthorOfBooksOnly,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$.store.book[*].author"),"Global")
set(#AllAuthors,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..author"),"Global")
set(#AllStoreThings,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$.store.*"),"Global")
set(#PriceOfEverythingInstore,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$.store..price"),"Global")
set(#ThirdBook,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[2]"),"Global")
set(#LastBook,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[(@.length-1)]"),"Global")
set(#LastBook2,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[-1:]"),"Global")
set(#First2books,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[0,1]"),"Global")
set(#First2books2,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[:2]"),"Global")
set(#BookswithISBNnumber,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[?(@.isbn)]"),"Global")
set(#CheaperThan10Books,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..book[?(@.price<10)]"),"Global")
set(#AllElementsInJson,$plugin function("JSONpath.dll", "$JSONpath parser", #testdata, "$..*"),"Global")

Link to post
Share on other sites
  • 3 months later...
  • 1 month later...
  • 3 weeks later...

Download link updated

 

 

downloads dont work anymroe from the email that is sent :(

 

Plese update if you get a chance!

 

 

Any chance you could update the download links? They return a AWS error.

 

 

Yes, can you please update this? Are you alive buddy? :(

Link to post
Share on other sites
  • 3 weeks later...
  • 5 weeks later...

wow, this subject is over two years old and I'm afraid still unsolved. I tried this plugin and found the same problems with the filter.

 

Is there really no solution to parse json and filter properly within ubot?

Link to post
Share on other sites
  • 5 weeks later...
  • 1 year later...
  • 4 weeks later...

Hi Aymen, tried downloading the plugin and seems the link isn't working. Are you still providing the plugin?

 

Thanks!

Link to post
Share on other sites
  • 1 month later...
  • 4 months later...

It's working for me. Is your json xpath right?

 

example: $.object.item

 

 

I tested it using a json array from cli.fyi/bat

 

using the json xpath $.data.USD ($) to get the price for BAT, and it worked.

ui button("Check price") {
    navigate("https://cli.fyi/bat","Wait")
    set(#PageGet,"\{{$page scrape("\{","\}")}\}","Global")
    set(#PriceCheck,$plugin function("JSONpath.dll", "$JSONpath parser", #PageGet, "$.data.USD ($)"),"Global")
}
ui stat monitor("Price",#PriceCheck)
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...