Skip to main content
Question

Nested Json templater

  • December 18, 2018
  • 3 replies
  • 18 views

jatoxa
Contributor
Forum|alt.badge.img+12

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

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 18, 2018

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.


jatoxa
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • December 18, 2018
takashi wrote:

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?

jatoxa
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • December 18, 2018
takashi wrote:

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.

 

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings