3 Replies Latest reply on Jun 21, 2017 10:16 PM by liliu RSS
    xcheung Newbie

    About Convert JSON file to Infotable

    I follow the document: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS179012 to convert JSON file to Infotable, so I:

    1. Create the Datashape based on the JSON key and value.

    2. Create the service to getJSON file, and the code is:

     

    var params = {

    proxyScheme: undefined /* STRING */,

    headers: undefined /* JSON */,

    ignoreSSLErrors: true /* BOOLEAN */,

    useNTLM: undefined /* BOOLEAN */,

    workstation: undefined /* STRING */,

    useProxy: undefined /* BOOLEAN */,

    withCookies: undefined /* BOOLEAN */,

    proxyHost: undefined /* STRING */,

    url:"http://servername/rest/sql/list/site/",

    timeout: undefined /* NUMBER */,

    proxyPort: undefined /* INTEGER */,

    password: undefined /* STRING */,

    domain: undefined /* STRING */,

    username: undefined /* STRING */

    };

     

    // result: JSON

    var data = Resources["ContentLoaderFunctions"].GetJSON(params);

     

     

    var params = {

    infoTableName: undefined /* STRING */,

    dataShapeName: "TestJSON" /* DATASHAPENAME */

    };

     

    // result: INFOTABLE

    var jsonTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

    for(var i=0;i<data.length;i++)

    {

     

        jsonTable.AddRow({id:data.array[i].id, area:data.array[i].area, group:data.array[i].group, WS_name:data.array[i].WS_name, state:data.array[i].state, child:data.array[i].child});

     

    }

    //}

    result = jsonTable;

     

    3. After save and test, the result is an empty infotable.

     

    Can anyone help?