Skip to main content
Question

Parsing JSON File

  • November 21, 2013
  • 2 replies
  • 22 views

Forum|alt.badge.img
There must be an easy way to read a JSON file like the one I have below, and create a stream of feature objects, each with the attributes (idx, type, path, date) but I am missing how to do this (FME2014). 

 

 

If I use the JSON reader, I get a flattened list with lots of attributeX values. (yes, that is what the doc says it does).

 

 

I see some examples of people using the FileTextReader and then JSONFlatten  it out and exposing attributes. Is that the way to go? I think this should be easy, and yes, the path is a windows UNC, so I want to be able to use the in the RasterReader transform, I hope it understands UNCs.

 

 

{  "Zoom" : 9,  "CenterLat" : 50.055084228515625,  "CenterLon" : 19.938812255859375,  "FrameList" : [   {    "idx" : "22504704",    "type" : "CIB10",    "path" : "\\\\\\\\TEST-EGPL\\\\F\\\\SIS\\\\NGA\\\\CIB\\\\CB10S0009601\\\\RPF\\\\N51E020\\\\000MJ046.I13",    "date" : "1995-03-06T06:43:06.000Z"   },   {    "idx" : "22504705",    "type" : "CIB10",    "path" : "\\\\\\\\TEST-EGPL\\\\F\\\\SIS\\\\NGA\\\\CIB\\\\CB10S0009601\\\\RPF\\\\N51E020\\\\000MJ126.I13",    "date" : "1995-03-06T06:43:07.000Z"   },   {    "idx" : "22504706",    "type" : "CIB10",    "path" : "\\\\\\\\TEST-EGPL\\\\F\\\\SIS\\\\NGA\\\\CIB\\\\CB10S0009601\\\\RPF\\\\N51E020\\\\000MJ226.I13",    "date" : "1995-03-06T06:43:08.000Z"   },   {    "idx" : "22504708",    "type" : "CIB10",    "path" : "\\\\\\\\TEST-EGPL\\\\F\\\\SIS\\\\NGA\\\\CIB\\\\CB10S0009601\\\\RPF\\\\N51E020\\\\000MJ326.I13",    "date" : "1995-03-06T06:43:08.000Z"   },

 

........

 

 

 

 

 

 

2 replies

fmelizard
Safer
Forum|alt.badge.img+18
  • Safer
  • November 21, 2013
Hi,

 

 

FileTextReader and then JSONFlatten  it out and exposing attributes. Is that the way to go? I think this should be easy

 

 

Well that is easy, with just 3 transformers (JSONFlattener, AttributeExposer and ListExploder) you have all of your attributes available.

 

 

Itay

Forum|alt.badge.img
  • Author
  • November 22, 2013
Yes, I got it to work with 4 transformers and the FileTextReader (see below) but usually things in FME are more intuitive. I would have expected that the JSONReader would "actually" have been useful in reading JSON, and it could do a simple thing like  this in one step.

 

 

I only say this because the SAFE folks once asked me to report back on things that take too long, and if there is any collapsing of controls that would be useful.

 

 

Are you listening SAFE?

 

  1. JSON Flattener
  2. Attribute Remover
  3. List Exploder
  4. Attribute Exposer

 

 


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