Question

Nested Json templater

  • 18 December 2018
  • 3 replies
  • 0 views

Badge +2

Hi all,

 

 

I need to build a nested Json structure similar to a folder structure. Is it possible to do with the JsonTemplater wihtout a lot of sub-templates?

 

I want something more dynamic or alternatively I have to post-process the Json.

 

 

Thanks!

 

 

/Jacob

3 replies

Userlevel 2
Badge +17

It depends on the structure of attributes in the input feature and your desired JSON structure, so it's hard to say whether it's possible generally. In some cases it might be possible with XQuery (JSONiq extension) expressions.

Badge +2

It depends on the structure of attributes in the input feature and your desired JSON structure, so it's hard to say whether it's possible generally. In some cases it might be possible with XQuery (JSONiq extension) expressions.

Hi @takashi,

 

 

Thanks for your reply.

 

 

Let's say it's a "normal" folder structure with a root folder and an unknown number of sub-folders that can also have sub-folders.

 

Each folder have an "id" a "title" and a "parent_id".

 

 

In my mind it should be fairly easy to automatically link child nodes where a parent_id exists and they correspond?
Badge +2

It depends on the structure of attributes in the input feature and your desired JSON structure, so it's hard to say whether it's possible generally. In some cases it might be possible with XQuery (JSONiq extension) expressions.

I think I just had a mental blockage when I posted this. I managed to get exactly the desired result by using conditional expressions in the JsonTemplater.

 

This way I can recreate the entire hierarchical structure with only one sub-template.

 

 

 

Reply