Skip to main content
Solved

Expanding JSON output with an array into features


simeon
Contributor
Forum|alt.badge.img+2

I’ve tried searching for answers to this but I’m sure I must be using the wrong search terms as I get close matches but nothing that has pointed me in quite the right direction yet. I’m hopefully that someone can help me understand how to expand the following JSON fragment into a set of features, where each feature contains the same initial set of fields, but only contains one of the final array entries.
Here’s an edited example of the JSON I’m dealing with and how I’d like the out to look.

 

{"UPRN":"12345678",

"CaseNo":"15/01234/ABCDE",

"Address":"16 Some Rd Surrey SM1 1AA",

"Name":"Miss T Mountain",

"DocumentID":["7654321","7654322","7654323"]}

I’m trying to extract this into 3 features, each of which includes the uprn, CaseNo, address, name and a DocumentID.

 

I’ve been able to extract the whole array of documentIDs but haven’t figured out how to extract each one in turn and pair it up with the remaining information.

The JSON output I’m dealing with contains a number of such records, in each case the number of document IDs is between 1 and many, so I can’t create explicit references to entries within the array.

I’ve been experimenting with the JSONFragmenter and JSONExpander. I think I just need to understand how to reference the internals of this structure properly.

If anyone can offer me some help to understand how to do this, I would be grateful.

Best answer by geomancer

A JSONFlattener (with Recursive Flattening) where you expose the attributes, followed by a ListExploder, should do the trick.

 

View original
Did this help you find an answer to your question?

3 replies

geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • Best Answer
  • April 9, 2024

A JSONFlattener (with Recursive Flattening) where you expose the attributes, followed by a ListExploder, should do the trick.

 


simeon
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • April 10, 2024

Many thanks, I’ve just been able to try that. I was a little concerned that I couldn’t see the DocumentID array in the output from the flattener but persevered anyway to the ListExploder, which was able to recognise that a list was present in that attribute name. From what I can see, I now have the full list of documents alongside the other information in a set of features that I can progress with.


geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • April 10, 2024

I'm glad I could help.

simeon wrote:

[…] I was a little concerned that I couldn’t see the DocumentID array in the output from the flattener [...]

Lists are not shown in the Tabel View, but you can see them in the Feature Information Window.


Reply


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