Skip to main content
Question

Nested Json templater

  • December 18, 2018
  • 3 replies
  • 23 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
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

takashi
Celebrity
  • 7843 replies
  • 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
  • 65 replies
  • 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.

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
  • 65 replies
  • 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.

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.