cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

How to create json from infotable using ToJson method?

bgupta-2
10-Marble

How to create json from infotable using ToJson method?

Dear Team,

I am getting tabular data  after calling below code as result output is JSON.

var params = {

  

    oldestFirst: undefined /* BOOLEAN */,

  maxItems: undefined /* NUMBER */,

  sourceTags: undefined /* TAGS */,

  endDate: undefined /* DATETIME */,

  query: undefined  /* QUERY */,

  source: undefined/* STRING */,

  startDate: undefined /* DATETIME */,

  tags: undefined /* TAGS */

  

};

// result: INFOTABLE

var result2 = Things["PumpValueStream"].QueryStreamEntriesWithData(params);

var params = {

  table: result2 /* INFOTABLE */

};

// result: JSON

var result = Resources["InfoTableFunctions"].ToJSON(params);

1 REPLY 1
posipova
20-Turquoise
(To:bgupta-2)

Hi, below is a simple example of using toJson snippet, converting from an existing infotable (with a datashape) to json:

Or with a query,

Keep in mind such a result would be displayed in a tabular format. However, you may save it to, for example, a property

result = table1.ToJSON();

Then when the property is assigned the converted toJson data, you will see the following:

Announcements


Top Tags