Skip to main content
1-Visitor
December 18, 2017
Question

How can I use json file in Thingworx Composer..?

  • December 18, 2017
  • 2 replies
  • 3322 views

Hello, I'm Sol

I have some questions. I wanna use Json file in Thingworx but I don't know how to use in Thingworx Composer.

//-------start-----------

$subscriptionKey = '440dd540-8db1-3f5d-806e-9b15d5b4bece';


getWeather();


function getWeather() {

$subscriptionKey = '440dd540-8db1-3f5d-806e-9b15d5b4bece';

   

$(function() {

     var params = {

            version: 1,

            city : "서울",

            county : "강남구",

            village : "도곡동"

};

        //http://apis.skplanetx.com/weather/forecast/3hours?

$.ajax({

url: "http://apis.skplanetx.com/weather/current/minutely?" + $.param(params),

beforeSend: function(xhrObj){

// Request headers

xhrObj.setRequestHeader("appKey",'440dd540-8db1-3f5d-806e-9b15d5b4bece');

},

type: "GET",

// Request body

data: "{body}",

})

.done(function(data) {

document.write("successss");

         

            document.write(JSON.stringify(data));

            //console.table(data);

           

})

.fail(function() {

alert("error");

});

});

}

//----------end--------------

that is my jason file code and I wanna print this code in thingworx.

/*----------start----------------*/

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>weather info</title>

<style>

</style>

</head>

<body>

      

    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>

    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<script type="text/javascript" src="test.js"></script>

<div class="result">

<p id="resultInfo">ggg </p>

    </div>


    <script type="test/javascript">

       

   

    </script>

   


</body>

</html>


/*----------end----------------*/


That information is forecast information from south Korea.


Can I connect this kind of code with Thingworx? I just need to print weather values in Thing worx.

2 replies

22-Sapphire I
December 18, 2017

In Thingworx for XML it uses E4X so that if you read an XML page it become an object that you can traverse as nodes.

Same for JSON if you read something in as JSON object it can be traversed as nodes, if the JSON is an Array then it will be nodeVariable.array.[nameofnode]

hkim-511-VisitorAuthor
1-Visitor
December 19, 2017

Could explain more detail..? How can I use that javascript code in Thinsworx Composer?

16-Pearl
December 20, 2017

It looks like you are trying to bro g javascript libraries. Take a look at Widget Extensions Using AAGRID a JS library