Yeah I think the old one was Xojo code
And the new one based the code in the Xojo framework using GenerateJSON so its underpinnings are all in C++
And it DIDNT honour the DecimalFormat that I recall
Nor support Currency - not sure why though
Mines not intended to be a drop in replacement
its mean to be even more “natural”
So to set an items with a key and an array of values you can just do
dim j as new GWSJsonItem
j.add("key") = array("123", "456")
and this would create
{ "key" : [ "123", "456"] }
And some other shortcuts like arrays of classes as long as they implement a really simple interface
EDIT : for instance to serialize a bunch of settings from a class (in this case from my CONSOLE test app) to JSON
I can do the following
- implement the ICustomJsonValue interface in my App class (just for fun) as follows
Dim g As New GWSJSONItem
Dim g2 As New GWSJSONItem
g2.value("MajorVersion") = Self.MajorVersion
g.append g2
g2 = New GWSJSONItem
g2.value("MinorVersion") = Self.MinorVersion
g.append g2
g2 = New GWSJSONItem
g2.value("BugVersion") = Self.BugVersion
g.append g2
g2 = New GWSJSONItem
g2.value("NonReleaseVersion") = Self.NonReleaseVersion
g.append g2
g2 = New GWSJSONItem
g2.value("Copyright") = Self.Copyright
g.append g2
g2 = New GWSJSONItem
g2.value("ExecutableFile.NativePath") = Self.ExecutableFile.NativePath
g.append g2
g2 = New GWSJSONItem
g2.value("ShortVersion") = Self.ShortVersion
g.append g2
g2 = New GWSJSONItem
g2.value("StageCode") = Self.StageCode
g.append g2
g2 = New GWSJSONItem
g2.value("Version") = Self.Version
g.append g2
Return g.ToString
this code will return an array of JSON items each with a name & value
- code the following
Dim g As New GWS.GWSJSONItem
g.Value("App") = App // yes I can put the App in the JSON
Print g.tostring
Dim j As Variant = ParseJSON(g.tostring) // test it generated proper JSON
and that Print statement prints out
{"App":[{"MajorVersion":1},{"MinorVersion":0},{"BugVersion":0},{"NonReleaseVersion":0},{"Copyright":""},{"ExecutableFile.NativePath":"\/Users\/npalardy\/Great White Software\/RB Test Projects\/My Application.debug\/My Application.debug"},{"ShortVersion":""},{"StageCode":0},{"Version":""}]}