Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
{
"data": [
{
"usageId": "50030540014333322800000050",
"assetFound": true,
"compartments": {
"rows": [
{
"compartmentId": "50030540014333322800000052",
"observableProperties": {
"gatewayLocationDescription": "Ireland",
"temperature": 6,
"timestamp": 1612393200000
},
"compartmentUsage": {
"compartmentState": "Inuse",
"minTemperatureThreshold": 2.2
}
},
{
"compartmentId": "50030540014333322800000051",
"observableProperties": {
"gatewayLocationDescription": "Belgium",
"temperature": 2,
"timestamp": 1612220400000
},
"compartmentUsage": {
"compartmentState": "Idle"
}
}
],
"dataShape": {
"fieldDefinitions": {
"compartmentId": {
"name": "compartmentId",
"aspects": {
"isPrimaryKey": false
},
"description": "",
"baseType": "STRING",
"ordinal": 1
},
"observableProperties": {
"name": "observableProperties",
"aspects": {
"isPrimaryKey": false
},
"description": "",
"baseType": "JSON",
"ordinal": 3
},
"compartmentUsage": {
"name": "compartmentUsage",
"aspects": {
"isPrimaryKey": false
},
"description": "",
"baseType": "JSON",
"ordinal": 2
}
}
}
}
}
],
"message": "Information found",
"status": "Success"
}
Hi @KN_9774047
You can refer to below link to get rid of datashape fields coming along in your JSON output:
Remove DataShapes from JSON Output
Do revert for more queries.
Regards,
Sudeepta
Tried that way in Thingworx 9.0.3 but not working out.
datShape field is still showing up in the output
Hi @KN_9774047
I gave the code a try in 9.0.3 and able to get output without datashape. Sharing my script for reference:
var params = {
infoTableName: undefined /* STRING */,
dataShapeName: "DS" /* DATASHAPENAME */
};
// result: INFOTABLE
var result1= Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var newEntry = new Object();
newEntry.name = "test1"; // STRING - isPrimaryKey = true
newEntry.value = "test 1"; // STRING - isPrimaryKey = true
result1.AddRow(newEntry);
newEntry.name = "test2"; // STRING - isPrimaryKey = true
newEntry.value = "test 2"; // STRING - isPrimaryKey = true
result1.AddRow(newEntry);
newEntry.name = "test3"; // STRING - isPrimaryKey = true
newEntry.value = "test 3"; // STRING - isPrimaryKey = true
result1.AddRow(newEntry);
var param = {
table: result1 /* INFOTABLE */
};
var result = Resources["InfoTableFunctions"].ToJSON(param);
result.array = result.rows;
delete result.rows;
delete result.dataShape;
Could you attach your service code here if still not getting output without DataShape.
I am not allowed share the code.
But mine is a nested JSON.What you created is a straight forward one. It's not working with my output(nested)
Hi @KN_9774047.
If you would like, we can open a case for further review of the problem. I will be happy to open the case on your behalf.
Regards.
--Sharon
Thank you. It's help me!