Anonym 53 Posted April 28, 2013 Report Share Posted April 28, 2013 I am looking for a Json parser and I was considering to write one myself using the plugin interface until I realized that my own development would cost me money (the plugin API fee). What I am interested in is Json to/from XML and Json to/from CSV. Anyone who has one such parser for sale? It have to be lightning fast as the amount of data will be massive. Quote Link to post Share on other sites
Aymen 385 Posted April 28, 2013 Report Share Posted April 28, 2013 I could add a Jason to XML to my current XML plugin ! 1 Quote Link to post Share on other sites
Anonym 53 Posted April 28, 2013 Author Report Share Posted April 28, 2013 Really? How much would that cost me? Any chance of getting a CSV converter in there as well? XML <-> CSV and Json <-> CSV ? Quote Link to post Share on other sites
AutomationNinja 194 Posted April 28, 2013 Report Share Posted April 28, 2013 Isn't free to develop a plugin if it is shared with the community for free? Quote Link to post Share on other sites
Anonym 53 Posted April 28, 2013 Author Report Share Posted April 28, 2013 Yes, it is if you release it with the source code, but right now I am so ****** at the whole concept that I prefer someone else to do it. I'd rather support someone like Aymen that has invested his time into his quality plugins (that is, this is an optimal use of already released plugin keys ). Quote Link to post Share on other sites
Aymen 385 Posted April 28, 2013 Report Share Posted April 28, 2013 Really? How much would that cost me? Any chance of getting a CSV converter in there as well? XML <-> CSV and Json <-> CSV ? Yea i'll add those commands ideas to the Todo list ! Quote Link to post Share on other sites
beatngu 65 Posted April 29, 2013 Report Share Posted April 29, 2013 Yea i'll add those commands ideas to the Todo list !That would be cool,and great suggestion about the Json Anonym. Quote Link to post Share on other sites
UBotDev 276 Posted April 29, 2013 Report Share Posted April 29, 2013 JSON is already supported by JavaScript/$eval function, although you would need to add the exact functionality you want. Else I also think plugin would be a more robust solution. However, here is an example of UBot code: set(#json, "\{ \"firstName\": \"John\", \"lastName\" : \"Smith\", \"age\" : 25, \"address\" : \{ \"streetAddress\": \"21 2nd Street\", \"city\" : \"New York\", \"state\" : \"NY\", \"postalCode\" : \"10021\" \}, \"phoneNumber\": [ \{ \"type\" : \"home\", \"number\": \"212 555-1234\" \}, \{ \"type\" : \"fax\", \"number\": \"646 555-4567\" \} ] \}", "Global") set(#ADDRESS, $JSON Return Value("address.streetAddress", #json), "Global") set(#NAME, $JSON Return Value("firstName", #json), "Global") define $JSON Return Value(#JSON Key, #JSON Content) { return($eval("var tmp = {#JSON Content}; tmp.{#JSON Key}")) } Quote Link to post Share on other sites
orbital 15 Posted September 22, 2013 Report Share Posted September 22, 2013 Hey Aymen, any update on this getting added onto your xml plugin? Quote Link to post Share on other sites
whoami 26 Posted January 11, 2014 Report Share Posted January 11, 2014 This is a great post. JSON is already supported by JavaScript/$eval function, although you would need to add the exact functionality you want. Else I also think plugin would be a more robust solution. However, here is an example of UBot code: set(#json, "\{ \"firstName\": \"John\", \"lastName\" : \"Smith\", \"age\" : 25, \"address\" : \{ \"streetAddress\": \"21 2nd Street\", \"city\" : \"New York\", \"state\" : \"NY\", \"postalCode\" : \"10021\" \}, \"phoneNumber\": [ \{ \"type\" : \"home\", \"number\": \"212 555-1234\" \}, \{ \"type\" : \"fax\", \"number\": \"646 555-4567\" \} ] \}", "Global") set(#ADDRESS, $JSON Return Value("address.streetAddress", #json), "Global") set(#NAME, $JSON Return Value("firstName", #json), "Global") define $JSON Return Value(#JSON Key, #JSON Content) { return($eval("var tmp = {#JSON Content}; tmp.{#JSON Key}")) } But lets say I want to parse this JSON: http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=json into a CSV?How I would be able to do this? Is it possible? Quote Link to post Share on other sites
Code Docta (Nick C.) 638 Posted January 11, 2014 Report Share Posted January 11, 2014 Regex? Quote Link to post Share on other sites
UBotDev 276 Posted January 11, 2014 Report Share Posted January 11, 2014 Sure it's possible, but you need to manually parse each table cell entry (loop through all "rows"). To give you an idea: set(#TITLE, $JSON Return Value("feed.entry[\'0\'].title[\'$t\']", #json), "Global") set(#URL, $JSON Return Value("feed.entry[\'0\'].link[\'0\'].href", #json), "Global") Quote Link to post Share on other sites
whoami 26 Posted January 12, 2014 Report Share Posted January 12, 2014 Sure it's possible, but you need to manually parse each table cell entry (loop through all "rows"). To give you an idea: set(#TITLE, $JSON Return Value("feed.entry[\'0\'].title[\'$t\']", #json), "Global") set(#URL, $JSON Return Value("feed.entry[\'0\'].link[\'0\'].href", #json), "Global") So the feed.entry will be a counter to grab them all? Quote Link to post Share on other sites
beatngu 65 Posted January 12, 2014 Report Share Posted January 12, 2014 The way i do it is to grab them all and regex out the parts i want from the return value.Not the best way to do it but it works. Quote Link to post Share on other sites
UBotDev 276 Posted January 12, 2014 Report Share Posted January 12, 2014 So the feed.entry will be a counter to grab them all?Kind of...the number that is behind the feed.entry (0 in example above) will tell parser which row to grab. So you would replace that number with UBot variable and increment it in a loop. Of course REGEX is also an option if you are comfortable with it (you may need a bit more trial and error). Quote Link to post Share on other sites
JDJ 1 Posted January 14, 2014 Report Share Posted January 14, 2014 I would say definitely use regex for this for reasons of stability and speed. I've written a bot that parses through thousands of json responses from a few different APIs.. Originally I used the eval function to go through the results but the memory usage from browser.exe was massive with just a few hundred results, the speed was terrible, and occasionally there would be browser.exe crashes. Regular expressions worked quickly and without any issues. Quote Link to post Share on other sites
JDJ 1 Posted January 16, 2014 Report Share Posted January 16, 2014 I actually ran into some further issues with Json parsing and string manipulation that can be handled easily with Javascript, but unfortunately ran into out of memory errors when using Ubot's built in eval statement.. I tried opening and closing browsers to do the work, but this led to browser.exe crashes... so I decided to create a plugin that uses an alternative javascript engine to the one in the browser to do the eval work.. and it works great without the memory issues and extremely fast (actually.. testing out more scripting with it - it seems it may be even faster than Ubot at a lot of things). I'll apply for a plugin key, and see if I can release it as a free plugin. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.