Jump to content
UBot Underground

Best way to work with JSON?


Recommended Posts

I was looking at this the other day.  Couldn't find anything useful on working with JSON in Ubot, so I turned to MySQL.

 

Chances are if you are trying to work with JSON, you can do it with MySQL.  Of course there are reasons why you wouldn't be able to.

 

Some JSON features in Ubot would be great, but there are probably other bigger issues that are being resolved first.

 

My original idea, and this may help you as you have a dev license.  Request the JSON through a hidden browser, scrape the data and then do what you wish with it.

Link to post
Share on other sites
  • 11 months later...
  • 11 months later...

The http://www.ubotstudio.com/forum/index.php?/topic/13725-json-parser/?p=76556 is great and it works but it lacks the check for loaded HTML in the browser, the condition needed in order for eval to always run properly. See the full post here http://devmd.com/r/parsing-json-ubot-studio and below is the code for quick reference

define eval fix {
    set(#test,$eval("2+3"),"Local")
    if($comparison(#test,"=","")) {
        then {
            load html("An empty page was detected so eval() can not run. This is an auto generated HTML so that the function can be used!")
        }
    }
}
define $json value(#json, #key) {
    eval fix()
    return($eval("try\{var json_63a4e94d5e86 = {#json}; json_63a4e94d5e86.{#key};\}catch(err)\{json_63a4e94d5e86 = ''; json_63a4e94d5e86;\}"))
}
Edited by goceb
Link to post
Share on other sites

 

The http://www.ubotstudio.com/forum/index.php?/topic/13725-json-parser/?p=76556 is great and it works but it lacks the check for loaded HTML in the browser, the condition needed in order for eval to always run properly. See the full post here http://devmd.com/r/parsing-json-ubot-studio and below is the code for quick reference

 

 

Thanks to Aymen we have an easier way to deal with JSON now: http://www.ubotstudio.com/forum/index.php?/topic/16166-free-plugin-jsonpath-parser-plugin/

 

P.S.: For $eval to work you need JavaScript loaded inside the browser, HTML only won't help.

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...