pass json or dictionary as xojo script source

I am currently building json data manually for xojo script as the source (shown below) and it works ok.
I would imagine there is a better way.

dim Title as string ="""MyTitle""" dim fieldNames as string="{" + """Title"":" + Title +"," fieldNames = fieldNames + """SKU"":" + """ITEM NUMBER 2""" +"," fieldNames = fieldNames + """Body (HTML)"":" + """DESCRIPTION 1""" +"," fieldNames = fieldNames + """Title"":" + """ITEM NAME""" +"}" setCustomVals fieldNames

TIA

Tim

Yes, Xojo has JSON handling built in (and it’s a whole lot more straight forward than the XML objects)

http://documentation.xojo.com/index.php/JSONItem

[quote=323267:@Tim Parnell]Yes, Xojo has JSON handling built in (and it’s a whole lot more straight forward than the XML objects)

http://documentation.xojo.com/index.php/JSONItem[/quote]
Thanks, yes Xojo does but xojoscript does not.

Sorry, didn’t see the “script” part.
It’s technically XojoScript, and I was reading fast.
#blamingyou :stuck_out_tongue:

You can define your own json functions in a XojoScript context.

Then my XojoScripts look like this, for example:
https://www.seminar.pro/ScriptReference/JsonSetValueBoolean.htm

More examples here, from Scripts->JSON
https://www.seminar.pro/ScriptHelp/

[code]// Create a new JSON object
Dim handle As Integer = JsonCreate

If handle >= 0 Then

// Add key-value pairs to the JSON object
JsonSetValue(handle,“subject”,“title”)
JsonSetValueBoolean(handle,“member”,True)
JsonSetValue(handle,“email”,“support@seminar.pro”)

// Convert JSON object to a string
Dim js As String = JsonToString(handle)

// Show JSON string to user. It should look like this:
// {“subject”:“title”,“member”:true,“email”:“support@seminar.pro”}
MsgBox(js)

// Now we create a new JSON object from this string
handle = JsoncreateFromString(js)

// Retrieve Boolean value from new JSON object
// If member=true then we display YES
Dim msg As String = "Is member : " + If(JsonGetValueBoolean(handle,“member”),“YES”,“NO”)

// Show message with boolean value to user
MsgBox(msg)

End If[/code]