Author | Topic: Var2JSON() / JSON2Var() | |
---|---|---|
Jonathan Leeming | Var2JSON() / JSON2Var() on Fri, 04 May 2018 09:21:45 -0600 Hi, At the 2016 Southwest Xbase++ conference Venelina Jordanova gave a presentation which included JSON data formats. Following up on this I was looking through my Xbase++ 2.0 documentation (build 918) and the only references to the Var2JSON() function are in the build 547 change log and the "Xbase++ Developer Bookshelf". I can't find any other information on it. For "Fun" I included the following lines of code in my application... IF .F. Var2JSON(aEDebug1) JSON2Var(aEDebug2) ENDIF Recompiled without generating an error so I would assume that there is also a JSON2Var() function but I can't find a single reference to it. I realize the there are numerous deficiencies in the current documentation but I was expecting at least an entry with "TBD". Can anyone shed some light on these functions? Thanks... Jonathan jonathan.leeming@the-family-centre.com Edmonton, Alberta, Canada | |
Peter Alderliesten | Re: Var2JSON() / JSON2Var() on Mon, 07 May 2018 13:34:48 +0200 Jonathan, > I can't find any other information on it. For "Fun" I included the > following lines of code in my application... > > IF .F. > Var2JSON(aEDebug1) > JSON2Var(aEDebug2) > ENDIF > > Recompiled without generating an error so I would assume that there is > also a JSON2Var() function but I can't find a single reference to it. Nu, but I ran a little test on these functions. function main() local oInput := dataObject():new() local oOutput local cJson oInput:name := "John" oInput:age := 44 oInput:date := stod("20120304") cJson := var2Json(oInput) oOutput := Json2var(cJson) return nil When you start out with a dataObject, var2Json turns out a Json string. When you feed this string to Json2var, you would expect a dataObject back, but the same string is returned. So Json2var seems to be present as a dummy function. Peter | |
Boris Borzic | Re: Var2JSON() / JSON2Var() on Mon, 07 May 2018 15:04:41 +0200 I don't think Xbase++ provides full support for JSON. However, Xb2.NET does include full JSON support since v3.6. This includes converting between Xbase++ and JSON arrays AND objects. Two functions and one class are provided for this purpose: xbJSON class for creating, parsing and modifying JSON objects: https://xb2.net/xb2net/Xb2NET.htm#xbJSON xbJSONParse function converts a JSON string to an Xbase++ array or xbJSON object. xb2JSON function converts an Xbase++ array to a JSON string. Best regards, Boris Borzic http://xb2.net http://sqlexpress.net industrial strength Xbase++ development tools Jonathan Leeming wrote in news:4d4be965$24fd4ef9$b62cd2@news.alaska- software.com: > At the 2016 Southwest Xbase++ conference Venelina Jordanova gave a > presentation which included JSON data formats. Following up on this I > was looking through my Xbase++ 2.0 documentation (build 918) and the > only references to the Var2JSON() function are in the build 547 change > log and the "Xbase++ Developer Bookshelf". > > I can't find any other information on it. For "Fun" I included the > following lines of code in my application... > > IF .F. > Var2JSON(aEDebug1) > JSON2Var(aEDebug2) > ENDIF > > Recompiled without generating an error so I would assume that there is > also a JSON2Var() function but I can't find a single reference to it. > > I realize the there are numerous deficiencies in the current > documentation but I was expecting at least an entry with "TBD". | |
Peter Alderliesten | Re: Var2JSON() / JSON2Var() on Wed, 30 May 2018 23:32:45 +0200 Jonathan, > ... For "Fun" I included the > following lines of code in my application... > > IF .F. > Var2JSON(aEDebug1) > JSON2Var(aEDebug2) > ENDIF > > Recompiled without generating an error so I would assume that there is > also a JSON2Var() function but I can't find a single reference to it. Well, they're there now. Build 951. Haven't tested them yet though. Peter | |
Jonathan Leeming | Re: Var2JSON() / JSON2Var() on Wed, 30 May 2018 17:09:36 -0600 On 5/30/2018 3:32 PM, Peter Alderliesten wrote: > Jonathan, > >> ... For "Fun" I included the >> following lines of code in my application... >> >> IF .F. >> Var2JSON(aEDebug1) >> JSON2Var(aEDebug2) >> ENDIF >> >> Recompiled without generating an error so I would assume that there is >> also a JSON2Var() function but I can't find a single reference to it. > > Well, they're there now. Build 951. > Haven't tested them yet though. > > Peter > Hi Peter... and thanks. I downloaded 951 earlier today and noticed the referenced to these two functions. After I saw your posting I took you test code from you previous posting and gave it a quick try. Appears that now it is functional however the help file documentation is in orange... Orange: The feature may be used in production and for developing new code. The interfaces are stable and future changes are not likely. However, some capabilities may be broken or do not behave as documented. The documentation is incomplete but correct. Cheers... Jonathan jonathan.leeming@the-family-centre.com Edmonton, Alberta, Canada |