Just wanted to chime in, since I was searching for this answer myself.
This proposed solution doesn't seem equivalent to what I want, as there are differences between a named query binding with "json" return format and JSON encoding a PyDataSet.
For example, using a namedQuery binding with json format gives the following:
{
"Id": 1,
"IsCritical": false,
"Order": 1,
"ValueTypeId": 1,
"ValueType": "float",
"ValidationOperatorId": 3,
"ValidationOperator": "Greater Than",
"ComparisonValueFloat": 7,
"ComparisonValueInt": null,
"ComparisonValueBool": null,
"ComparisonValueString": null,
"ComparisonValueDatetime": null,
"ComparisonValueDropdown": null
}
But using the proposed solution (system.util.jsonEncode
after using system.dataset.toPyDataset
) gives the following:
{"columns":[{"name":"Id","type":"java.lang.Long"},{"name":"IsCritical","type":"java.lang.Boolean"},{"name":"Order","type":"java.lang.Integer"},{"name":"ValueTypeId","type":"java.lang.Long"},{"name":"ValueType","type":"java.lang.String"},{"name":"ValidationOperatorId","type":"java.lang.Long"},{"name":"ValidationOperator","type":"java.lang.String"},{"name":"ComparisonValueFloat","type":"java.lang.Double"},{"name":"ComparisonValueInt","type":"java.lang.Integer"},{"name":"ComparisonValueBool","type":"java.lang.Boolean"},{"name":"ComparisonValueString","type":"java.lang.String"},{"name":"ComparisonValueDatetime","type":"java.util.Date"},{"name":"ComparisonValueDropdown","type":"java.lang.Long"}],"rows":[[1,false,1,1,"float",3,"Greater Than",7.0,null,null,null,null,null]]}