All Things WinBatch > WinBatch

**************** New JSON Extender (Experimental) *******************

(1/7) > >>

td:
The new JSON extender is available for download.

The JSON extender project along with several other languishing projects was initiated quite some time ago but never completed. This is the first one to finally meet the light of day.

What is JSON and why create a JSON WinBatch extender? To borough from the extender's help file, "JSON stands for JavaScript Object Notation and is a lightweight, easy to understand format used to store and transport data. It is often used to send data to and from websites and Internet based applications but it is increasingly used by local applications to store configuration and other data on the local system. "

Why do we call this pre-release extender "experimental"? In the world of software development, experimental releases are different from beta releases because beta releases are considered feature complete. Experimental releases may or may not be feature complete. The differences between a beta release and a final release are usually confined to bug fixes and performance improvements. The difference between experimental releases and final releases may include new or modified features.

We created the extender using a new-to-us software development approach and some new software development tools so it is experimental in those senses too.

You can download the extender by following the link below. You will need a current license to install the extender.

https://files.winbatch.com/downloads/wb/ilcjs44i.zip

Any constructive comments and suggestions are appreciated.

JTaylor:
Excellent.  Thank you.  One thing I would request that I have found helpful would be a way to list all the paths like I do in my Omnibus Extender.   That is VERY helpful for getting a feel for the data and paths.   Maybe if the key-name in jsKeyPaths() was left blank it would list out all the paths from that point down?   Option to list value at the end of appropriate paths would be icing on the cake.



Jim

P.S.  If anyone is using the JSON portion of my Extender I recommend you switch and let me know.  Once I am somewhat sure no one is using it or at least some time passes I will be removing JSON support so I don't have to keep up with that part of the Omnibus Extender.   Thanks again Tony.   Hope to see the SQLite Extender next :)

td:
Actually, jsKeyPaths does return all paths if the key-name parameter is an empty string. Unfortunately, the fact just isn't mentioned in the help file. Will have to make sure that the situation is corrected.

Thanks for pointing it out.

stanl:

--- Quote from: td on September 09, 2021, 02:13:53 pm ---The new JSON extender is available for download.

--- End quote ---


Nice. Hope to find time this weekend to test with some REST queries.

stanl:

--- Quote from: stanl on September 10, 2021, 03:08:13 am ---Nice. Hope to find time this weekend to test with some REST queries.

--- End quote ---


Well, didn't take long to get a failure... probably something I did. Used the same weather alerts URL I tested with Jim's extender and Newtonsoft Json.  Got an invalid argument on the jsValid() function.

--- Code: Winbatch ---
;Winbatch 2021C - Test of new Json Extender
;uses  WinHttp.WinHttpRequest.5.1 for JSON return
;Stan Littlefield, September 10, 2021
;======================================================================================================
IntControl(73,1,0,0,0)
Gosub udfs
AddExtender('ilcjs44i.dll', 0, 'ilcjs64i.dll')
ar = "NJ" ;choose a different state to test outut
cUrl = "https://api.weather.gov/alerts/active?area=%ar%"
BoxOpen("Parsing:":cUrl,"Please Wait...")
cSerialize = Dirscript():ar:".txt"
If FileExist(cSerialize) Then FileDelete(cSerialize)        
request = Createobject("WinHttp.WinHttpRequest.5.1")
request.Open("GET", cUrl, @False )
request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
request.SetRequestHeader("Accept", "application/json")
request.Send()
jdata = request.ResponseText
request = 0


;just display Json text
Message("",jdata)
;=================================
Valid = jsValid(jdata)  ;fails with 'Invalid Argument'
;=================================
If Valid Then Result = 'String is valid JSON.'
Else Result = 'Sting is not valid JSON data'
Message(cURL,Result)


If Valid
   Object = jsParse(jdata)
   FormJson =  jsSerialize(Json ,@true, @JsonUTF8)
   jsObjClose()
   FilePut(cSerialize,FormJson)
Else
   jsObjClose()
Endif


Exit


:WBERRORHANDLER
geterror()
Terminate(@TRUE,"Error Encountered",errmsg)
Exit


:udfs
#DefineSubRoutine geterror()
   wberroradditionalinfo = wberrorarray[6]
   lasterr = wberrorarray[0]
   handlerline = wberrorarray[1]
   textstring = wberrorarray[5]
   linenumber = wberrorarray[8]
   errmsg = "Error: ":lasterr:@LF:textstring:@LF:"Line (":linenumber:")":@LF:wberroradditionalinfo
   Return(errmsg)
#EndSubRoutine




Return
 

Navigation

[0] Message Index

[#] Next page

Go to full version