Skip to main content
Solved

Split JSON into several features


oscard
Influencer
Forum|alt.badge.img+21

Hi.

I have the following .json file:

{    
"0": {
        "0": {
            "Group 1": {
                "Sub 1": 0, 
                "Sub 2": 70
            }, 
            "Group 2": {
                "Sub 3": 0, 
                "Sub 4": 29
            }, 
            "Group 3": {
                "Sub 5": 136, 
                "Sub 6": 120
            }
        }, 
        "1": {
            "Group 1": {
                "Sub 1": 0, 
                "Sub 2": 76
            }, 
            "Group 2": {
                "Sub 3": 1, 
                "Sub 4": 35
            }, 
            "Group 3": {
                "Sub 5": 157, 
                "Sub 6": 115
            }
        }
	},
"1": {
        "0": {
            "Group 1": {
                "Sub 1": 5, 
                "Sub 2": 72
            }, 
            "Group 2": {
                "Sub 3": 51, 
                "Sub 4": 2
            }, 
            "Group 3": {
                "Sub 5": 16, 
                "Sub 6": 20
            }
        }, 
        "1": {
            "Group 1": {
                "Sub 1": 50, 
                "Sub 2": 7
            }, 
            "Group 2": {
                "Sub 3": 17, 
                "Sub 4": 3
            }, 
            "Group 3": {
                "Sub 5": 17, 
                "Sub 6": 15
            }
        }
	}
}

The JSON Reader of FME reads it like a single feature with 2 attributes:

0684Q00000ArDcCQAV.png

What I want to do is split that feature into 2. One has to have the attrbiute "0" and the other one, the attribute "1". Instead of a feature with two attributes, I need two features with one attribute each.

Is that possible? I have made a mess with JsonExploders, JsonFlatteners and friends... but no luck so far.

Thanks for any help provided!

FME Desktop 2016

Best answer by takashi

Hi @oscard, I would read the JSON document with a Text File reader (Read Whole File at Once: Yes) and then fragment the document with a JSONFragmenter.

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

4 replies

mygis
Supporter
Forum|alt.badge.img+13
  • Supporter
  • May 30, 2017

Hi @oscard,

 

If you are using FME Desktop 2017, you can do that from the reader's property. It is easy and straightforward. Check the attached screenshots.

 

I hope this helps.

 

 

 


oscard
Influencer
Forum|alt.badge.img+21
  • Author
  • Influencer
  • May 30, 2017
mygis wrote:

Hi @oscard,

 

If you are using FME Desktop 2017, you can do that from the reader's property. It is easy and straightforward. Check the attached screenshots.

 

I hope this helps.

 

 

 

I'm using 2016 :(

 

 


takashi
Influencer
  • Best Answer
  • May 31, 2017

Hi @oscard, I would read the JSON document with a Text File reader (Read Whole File at Once: Yes) and then fragment the document with a JSONFragmenter.


oscard
Influencer
Forum|alt.badge.img+21
  • Author
  • Influencer
  • June 1, 2017
takashi wrote:

Hi @oscard, I would read the JSON document with a Text File reader (Read Whole File at Once: Yes) and then fragment the document with a JSONFragmenter.

That's what I want!

 

 

Thanks!! It's a pretty simple solution. I need to think outside the box when reading files. I was being stubborn with the JSON Reader.

 

 


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