Skip to main content
1-Visitor
August 6, 2021
Question

JSON Output to Infotable Output from API.

  • August 6, 2021
  • 1 reply
  • 3489 views

Hi,

I am developing some App in Thingworx. My mate has developed a an API Rest which If I send some JSON, it returns me another JSON.

I would like to work with this JSON and save info in order to create fields in Mashup and visualize, modify data, create new one, etc, but let's go step by step.

 

Let's Start:

 

The code I will send to the API is the following:

{
    "paramh":"",
    "language":"EN",
    "materialfilter": {
        "Materialid": "XXX",
        "Materialdesc": "XXX",
        "Materialclass": "XXX",
        "Materialsustitutive": "XXX"
        }
}

 

I can introduce some data to the XXX just to filter and get an específic JSON result . For example, If I write 1106 on Materialid, I will recieve the following JSON:

AitorP_0-1628233996527.png

Ok, now, I would like to show this JSON in a table or in same way, but as I recieve a "tree" JSON with fileds inside properties (max 3 levels of the tree) from the objects, I would like to know how must be implemented in Thingworx, is there any way to save all the objects somwhere with all data under each property?Some Table? I don't know.

 

I explain what I have done since now:

 

Just to start, I have created a Mashup to filter the "query" where each Field Text is linked to an Input of a Service of a Think but it does not work yet:

AitorP_1-1628234855009.png

 

The Service is the following:

AitorP_2-1628235007841.png

The output, as you can see on the picture attached is a JSON, the same JSON i pasted before, if I execute just the servide on the Thing, it works well.

 

So please, how can I do to save the objects i recieve from JSON ? Creating a Table? Storing it in some place?

 

Thanks in advance,

 

Aitor.

 

1 reply

22-Sapphire I
August 6, 2021

You can store them in a Stream/ValueStream or last option DataTable.

However why do you need to store them and how are you going to use the stored information?

That will determine which route is likely the better one.

AitorP1-VisitorAuthor
1-Visitor
August 9, 2021

Hi PaiChung,

 

Thanks for your answer.

 

My goal is the creation of a mashup similar as this one:

AitorP_0-1628490384797.png

So, as you can see, on the JSON I recieve I have data to show in a Table and I have data to show in a kind of fields.

 

I think I really do not need to store data If I can work with them from JSON to the destination where I really want to show it on the mashup. But the problem is that I do not know how to "store" or "link" the data I recieve to the mashup because as I wrote it, I have different levels on the objects on the JSON.

 

Thanks in advance.

 

Aitor

22-Sapphire I
August 9, 2021

You will have to convert the JSON into an InfoTable in your service and use that in your mashup (you can do InfoTable inside InfoTable if needed)