Skip to main content
Solved

Proces nested json with task through indicium

  • 14 June 2024
  • 5 replies
  • 96 views

Hi,

I’m trying the following. I have a task that inserts a row in a table ‘input_json’. This task is called as an endpoint, so a supplier can insert some data. The task works, but I have two issues; 

The JSON: 

{
"id": 123456789,
"package-id": "",
"timestamp": 1718105305,
"location": "Rotterdam",
"measurements": {
"dimensions": {
"height": 100.0,
"width": 100.0,
"depth": 100.0},
"weight": 100.00
}
}

My task fails to read the nested values. When I remove the nesting from the JSON and post, it works ok. How can this be mapped accordingly? 

Secondly, the key ‘package-id’ has a score. SF always change my score (-) in the task parameter to a lower score, resulting that the value isn’t saved.

How can these two issues be resolved?

Thanks and kind regards!

Blommetje

This topic has been closed for comments

5 replies

Userlevel 5
Badge +13

Any thoughts on this?

Userlevel 7
Badge +23

I’m not entirely sure the platform can handle nested JSON structures like this one, but you can always use the method of having one task parmeter that contains all JSON data, and thereafter parse and process it via logic.

Secondly, the key ‘package-id’ has a score. SF always change my score (-) in the task parameter to a lower score, resulting that the value isn’t saved

The platform does not allow - but rather converts that to _, that is the intended behavior. The method above can circumvent that. Maybe other Community members can chime in.

Userlevel 5
Badge +13

Hi Mark, 

Yes, that would also be a good solution. I've tried this, but so far I've not got the entire JSON data. 
How can I create a parameter that will 'accept’ all data? 

Thanks! 

Blommetje

Userlevel 7
Badge +23

Hey, 

You could also opt to use a subroutine with API option on. That will make it available via the API through POST as described here: OData API | Thinkwise Documentation (thinkwisesoftware.com)

Have one subroutine parameter called input_data for instance. The caller enters the (escaped) JSON data in this parameter. After that, the subroutine can process the received data.

Hope this helps!

Userlevel 5
Badge +13

Hi,

I've asked my client to flatten their JSON, so I can process accordingly. I'm surprised nested json isn't supported to be honest. 

Grabbing ALL data in one go could be nice, but also requires the client to adjust their json. Now it was not a big problem, but sometimes it's not possible. 

Are there are plans on supporting this in the future? 

Blommetje