1 Reply Latest reply on Apr 10, 2017 3:00 PM by polinao RSS
    bgupta Apprentice

    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);

      • Re: How to create json from infotable using ToJson method?
        polinao Collaborator

        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: