Skip to main content
Question

How can I extract de data under attributes section in the JSON file?


mda
Contributor
Forum|alt.badge.img+7
  • Contributor

Hello everyone,

 

I need to extract data from a json file. The problem is that I cannot use json extractor becuase the format of the json is a pit different. Can anyone of you guys help me with this?. I have attatched an example of the json file. I need to get all values under "attributes". When I try to extract the needed values I get an empty fields.

@takashi​ I hope you have sometime to have a look 🙏

 

Kind Regards,,,

6 replies

takashi
Influencer
  • August 29, 2020

Hi @mda​ , I think what you need is to fragment the JSON array named "attributes" and flatten every fragmented object. You can use either the regular JSON reader or the JSONFragmenter to do that.

 

JSONReader: In the Add Reader dialog, after specifying Format and selecting the file as its Dataset, open the reader parameters dialog and set the parameters with JSON Query mode, like this. Here, Feature Type name can be any.

json-reader-parameters

 

 

JSONFragmenter: Set the parameters like this.

jsonfragmenter-parameters

 

 

Other than entering a JSON Query into the Query column field directly, you can also use the Select Query dialog, in either the JSON Reader or the JSONFragmenter.

select-query


mda
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • September 3, 2020
takashi wrote:

Hi @mda​ , I think what you need is to fragment the JSON array named "attributes" and flatten every fragmented object. You can use either the regular JSON reader or the JSONFragmenter to do that.

 

JSONReader: In the Add Reader dialog, after specifying Format and selecting the file as its Dataset, open the reader parameters dialog and set the parameters with JSON Query mode, like this. Here, Feature Type name can be any.

json-reader-parameters

 

 

JSONFragmenter: Set the parameters like this.

jsonfragmenter-parameters

 

 

Other than entering a JSON Query into the Query column field directly, you can also use the Select Query dialog, in either the JSON Reader or the JSONFragmenter.

select-query

Thank you ver much! That helps. I always mislocating the [*].


mda
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • January 15, 2021

@Takashi Iijima​ ​ Further to my previous question, I get now two attributes "Naam" en "Value". The contents of the "Naam"attribute are actually attributes names and the contents of the "Value"attrbute are the values. So what I need is to transpose the "Naam" attribute to columns and fill those columns with the content of the "Value"attribute (see attachments). I have tried attributepivoter and also attribute Transposer custom transformer. Unfortunatley, I keep getting nothing useful or empy output. Could you please help me with this!


mda
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • January 15, 2021

This is the wanted results form wanted result


nampreetatsafe
Safer
Forum|alt.badge.img+12
mda wrote:

This is the wanted results form wanted result

Looks like you got an answer to your question here: https://community.safe.com/s/question/0D54Q00008NouBwSAJ/how-can-i-transpose-a-column-which-was-extracted-from-a-json-file


mda
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • January 20, 2021
nampreetatsafe wrote:

Yes, I needed to use AttributeExposer after the AttributeTranspose :)


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