Skip to main content
Question

Need help reading JSON file

  • October 23, 2015
  • 5 replies
  • 140 views

Hello everyone,

 

 

I am new to using FME. The goal I am trying to achieve is to read in JSON data and write it to a File Geodatabase. I have watched the webinar: http://www.safe.com/webinar/fme-and-json/ and found it to be very helpful. I was even able to read in one JSON file and write it successfully to a Excel file. 

 

 

I am now using a different JSON file and I was trying to use the same steps as with the one before that worked but it's not working the same with this one.

 

 

Here is a snapshot showing the translation that worked:

 

 

Here is a snapshot showing the translation that is not working:

 

 

On the first one that works I was able to find in the log file the proper attribute names to use in the AttributeExposer but when i try doing the same with the one that doesn't work I can't seem to find anything in the log that shows the attribute names.

 

 

Here is what the JSON looks like in the translation that is not working:

 

 

{

 

   "Data" : {

 

      "crs" : {

 

         "properties" : {

 

            "name" : "urn:ogc:def:crs:EPSG::4326"

 

         },

 

         "type" : "name"

 

      },

 

      "features" : [

 

         {

 

            "geometry" : {

 

               "coordinates" : [

 

                  -113.971122645723,

 

                  51.0556601452916

 

               ],

 

               "type" : "Point"

 

            },

 

            "id" : 0,

 

            "properties" : {

 

               "Address" : "1836 3 ST SE",

 

               "Community" : "FOREST",

 

               "CompletionDate" : "2010/12/22",

 

               "ExternalFilenum" : "BP2010-11111",

 

               "StickerNumber" : "10",

 

               "URL" : "#",

 

               "Ward" : "10"

 

            },

 

            "type" : "Feature"

 

         },

 

         {

 

            "geometry" : {

 

               "coordinates" : [

 

                  -114.041387596826,

 

                  51.0365724925218

 

               ],

 

               "type" : "Point"

 

            },

 

            "id" : 1,

 

            "properties" : {

 

               "Address" : "4 8 ST NE",

 

               "Community" : "BRIDGESIDE",

 

               "CompletionDate" : "2006/12/09",

 

               "ExternalFilenum" : "BP2006-22222",

 

               "StickerNumber" : "5",

 

               "URL" : "#",

 

               "Ward" : "09"

 

            },

 

            "type" : "Feature"

 

         },

 

         {

 

            "geometry" : {

 

               "coordinates" : [

 

                  -114.00531425851,

 

                  51.0513769479828

 

               ],

 

               "type" : "Point"

 

            },

 

            "id" : 2,

 

            "properties" : {

 

               "Address" : "1 LEN DR SE",

 

               "Community" : "END",

 

               "CompletionDate" : "2002/10/11",

 

               "ExternalFilenum" : "BP2002-33333",

 

               "StickerNumber" : "1",

 

               "URL" : "#",

 

               "Ward" : "09"

 

            },

 

            "type" : "Feature"

 

         },

 

         {

 

            "geometry" : {

 

               "coordinates" : [

 

                  -114.138878544584,

 

                  50.9761875223377

 

               ],

 

               "type" : "Point"

 

            },

 

            "type" : "Feature"

 

         }

 

      ],

 

      "type" : "FeatureCollection"

 

   }

 

}

 

 

Thanks for any help,

 

Chris
Did this help you find an answer to your question?

5 replies

takashi
Influencer
  • October 24, 2015
Hi Cris,

 

 

In the JASON document you pasted, the "features" object is a member of the "Data" object, so the list name created by the JSONFlattener will be "Data.features{}". Try exposing "Data.features{}", instead of "features{}".

 

 

Once connect an Inspector to the JSONFlattener, run the workspace, and then look at the contents of the feature with the Feature Information window of FME Data Inspector. You can see how the JSON document has been flattened by the transformer. The Inspector (FME Data Inspector) is always a useful and poweful tool when you have a question.

 

 

Takashi

takashi
Influencer
  • October 24, 2015
correction. "features" is not "object", it should be called "array" (an ordered list of values).

  • Author
  • October 24, 2015
Thank you I will try this next week. Good point about using the inspector. Lots to learn!

 

Chris

  • Author
  • October 30, 2015
takashi wrote:
Hi Cris,

 

 

In the JASON document you pasted, the "features" object is a member of the "Data" object, so the list name created by the JSONFlattener will be "Data.features{}". Try exposing "Data.features{}", instead of "features{}".

 

 

Once connect an Inspector to the JSONFlattener, run the workspace, and then look at the contents of the feature with the Feature Information window of FME Data Inspector. You can see how the JSON document has been flattened by the transformer. The Inspector (FME Data Inspector) is always a useful and poweful tool when you have a question.

 

 

Takashi

Thanks @takashi your suggestion solved my problem.

 

 

Chris

  • Author
  • October 30, 2015
takashi wrote:
Hi Cris,

 

 

In the JASON document you pasted, the "features" object is a member of the "Data" object, so the list name created by the JSONFlattener will be "Data.features{}". Try exposing "Data.features{}", instead of "features{}".

 

 

Once connect an Inspector to the JSONFlattener, run the workspace, and then look at the contents of the feature with the Feature Information window of FME Data Inspector. You can see how the JSON document has been flattened by the transformer. The Inspector (FME Data Inspector) is always a useful and poweful tool when you have a question.

 

 

Takashi

Thanks @takashi works great!


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