Converting Table Data to JSON for SQL Server Data Element Input

The task is to convert unbound table data consisting of a single row of embedded Checkbox views into a JSON form to ultimately save into a SQL Server database.

The SavePreferences event script follows:

The confounding error I receive follows:

What is really troubling is that if I copy and review the data from the table it appears to be a perfect example of JSON formatted data:

{
"Action": true,
"ActionState": false,
"ActionTimeStamp": false,
"ActionType": false,
"ActionUserEmail": false,
"DateAssigned": true,
"DateDue": true,
"Id": false,
"Notes": true,
"Owner": true,
"PctComplete": true,
"Progress": true,
"Segment": false,
"Site": true,
"Status": true
}

I don't understand what is wrong here and deeply appreciate any insight to resolve the error.

Please see, Wiki - how to post code on this forum. It's generally a good idea to post code rather than pictures of code. That way we can copy and test it or modify it in our replies. Post a cropped screengrab too if you think the context is useful.

You have (papering over some minor technicalities) a JSON structure - specifically, a json array/list containing JSON objects already; your property tree.
I don't see why you think you need to convert it into a PyDataset. You should be able to convert your Perspective property structure into a JSON string to insert in your query using system.util.jsonEncode.

1 Like

Thank you for the insight... I pledge to improve my future posts.

1 Like

Thank you for your proposed solution... implementing jsonEncode() it runs without error and now have an object to insert in the database.