Skip to main content

I'm trying to expose attribute only 'fill-opacity' from the below json.

{"type":"FeatureCollection","features":[{"geometry":{"type":"Polygon","coordinates":[[[-81.0007,29.2057],[-81.0055,29.2029],[-81.0105,29.205],[-81.0107,29.2097],[-81.0059,29.2125],[-81.0009,29.2104],[-81.0007,29.2057]]]},"type":"Feature","properties":{"stroke-opacity":0.9,"fill-opacity":0.9,"hail_size_in_int":0.5,"hail_size_in":"0.5-0.9 inches","stroke-width":0,"fill":"#FFFFC0"}}]}

It returns blank values. Can someone please help me ?

Try the following JSON query:

jsonj"features"]
  • ]"properties"]

  • @david_r - No, it doesn't work. It still have blank values.


    @david_r - No, it doesn't work. It still have blank values.

    I tested using FME 2017.1 and it worked fine with the json above.

     

    Could you perhaps post a sample workspace that demonstrates the issue?
    I tested using FME 2017.1 and it worked fine with the json above.

     

    Could you perhaps post a sample workspace that demonstrates the issue?
    @david_r and @fmeuser_gc I tested with succefull in FME 2018. Good job @david_r
    @david_r and @fmeuser_gc I tested with succefull in FME 2018. Good job @david_r
    @danilo_fme , @david_r - This still doesn't work. I'm using 2015.1 version. Can you please add workspace.

     


    Tagging in @takashi, @TiaAtSafe, @RylanAtSafe, @erik_jan


    I just tested with FME 2015.1.0.3 and it works fine.

    Try the attached minimal workspace. If it works for you, the problem could be something else entirely.

    jsonfragmenter.fmwt

     


    I couldn't get the example to work with "properties" in the query – instead I had to use it as a prefix in the attributes to expose:

    JSON Query: jsono"features"]

  •  

    Attributes to Expose: properties.fill-opacity

    Edit: Tested in FME 2018.0 Build 18295 macOS


  • I just tested with FME 2015.1.0.3 and it works fine.

    Try the attached minimal workspace. If it works for you, the problem could be something else entirely.

    jsonfragmenter.fmwt

     

    This also works in 2018.0 Build 18295 with JSONFragmenter Version 3 and after upgrading it to Version 7! I must have had a syntax issue when I tested with "properties".

     

     


    I just tested with FME 2015.1.0.3 and it works fine.

    Try the attached minimal workspace. If it works for you, the problem could be something else entirely.

    jsonfragmenter.fmwt

     

    This still doesn't work in 2015.1.3 version. But it is working in 2017.1 version.

     

    Will there be any different syntax in 2015.1 version?
    This still doesn't work in 2015.1.3 version. But it is working in 2017.1 version.

     

    Will there be any different syntax in 2015.1 version?
    Good news :)

     

     


    I couldn't get the example to work with "properties" in the query – instead I had to use it as a prefix in the attributes to expose:

    JSON Query: jsono"features"]

  •  

    Attributes to Expose: properties.fill-opacity

    Edit: Tested in FME 2018.0 Build 18295 macOS

  • This syntax doesn't work in 2015.1.3 version. I still get blank values with the above syntax

     

     

     


    This syntax doesn't work in 2015.1.3 version. I still get blank values with the above syntax

     

     

     

    Hmm, that's very strange that the FME 2015.1.3 install will not work with either JSON Query posted as comments. Looking at the changelog nothing is jumping out at me to explain this behaviour..

     

    I tested on 2015.1.3.2 Build 15575 and it works. What build do you have installed, @fmeuser_gc?

     


    Hmm, that's very strange that the FME 2015.1.3 install will not work with either JSON Query posted as comments. Looking at the changelog nothing is jumping out at me to explain this behaviour..

     

    I tested on 2015.1.3.2 Build 15575 and it works. What build do you have installed, @fmeuser_gc?

     

    @RylanAtSafe - I have same version installed with same build 15575

     


    @RylanAtSafe - I have same version installed with same build 15575

     

    I tested in Win32 and Win64 – both give correct results. Perhaps try reinstalling FME 2015.1.3.2 if you have a requirement to use that version?

     

    https://www.safe.com/support/support-resources/fme-downloads/archived/

     

     

    If the issue persists, you may consider contacting Safe Support for a more thorough investigation.

     


    @RylanAtSafe - I have same version installed with same build 15575

     

    Can you please attach 2015 version workspace?

     

     


    Can you please attach 2015 version workspace?

     

     

    I just used the template shared by david_r – but saved it in 15575 and attached here. jsonfragmenter-15575.fmw

     


    I couldn't get the example to work with "properties" in the query – instead I had to use it as a prefix in the attributes to expose:

    JSON Query: jsonp"features"]

  •  

    Attributes to Expose: properties.fill-opacity

    Edit: Tested in FME 2018.0 Build 18295 macOS

  • When you set GEOJSON to the 'Explode as Format ' parameter, the JSONFragmenter attempts to fragment the source JSON document into individual Features

     

    {
       "geometry" : {
          "type" : "Polygon",
          "coordinates" : t ... ]
       },
       "type" : "Feature",
       "properties" : {
          "stroke-opacity" : 0.9,
          "fill-opacity" : 0.9,
          "hail_size_in_int" : 0.5,
          "hail_size_in" : "0.5-0.9 inches",
          "stroke-width" : 0,
          "fill" : "#FFFFC0"
       }
    }
    and then flatten the "properties" object. In this case, strictly saying, the JSON query should be this one which fragments the source JSON document into individual GeoJSON Features.

     

    jsont"features"]
  • However, even if you have set GEOJSON to the 'Explode as Format' parameter, FME seems to treat the parameter as JSON when the JSON query is not correct to fragment the source document into GeoJSON Features. Result, this query could also return the expected result.

     

    jsone"features"]
  • e"properties"]
  •  Probably you find this warning message on the Translation Log.

     

    JSONFragmenter(JSONQueryFactory): The JSON text could not be parsed as 'GEOJSON', parsing as plain JSON instead
    I suspect that a specific build of FME won't perform the automatic reinterpretation on the 'Explode as Format'. Could you check this? @RylanAtSafe
    This still doesn't work in 2015.1.3 version. But it is working in 2017.1 version.

     

    Will there be any different syntax in 2015.1 version?
    The syntax should be the same in all FME versions, as long as there isn't a bug in that particular version.

    Inspired by the comment from @takashi here, what happens if you set Explode as format = JSON rather than GEOJSON?


    When you set GEOJSON to the 'Explode as Format ' parameter, the JSONFragmenter attempts to fragment the source JSON document into individual Features

     

    {
       "geometry" : {
          "type" : "Polygon",
          "coordinates" : o ... ]
       },
       "type" : "Feature",
       "properties" : {
          "stroke-opacity" : 0.9,
          "fill-opacity" : 0.9,
          "hail_size_in_int" : 0.5,
          "hail_size_in" : "0.5-0.9 inches",
          "stroke-width" : 0,
          "fill" : "#FFFFC0"
       }
    }
    and then flatten the "properties" object. In this case, strictly saying, the JSON query should be this one which fragments the source JSON document into individual GeoJSON Features.

     

    jsonÂ"features"]
  • However, even if you have set GEOJSON to the 'Explode as Format' parameter, FME seems to treat the parameter as JSON when the JSON query is not correct to fragment the source document into GeoJSON Features. Result, this query could also return the expected result.

     

    json "features"]
  • s"properties"]
  •  Probably you find this warning message on the Translation Log.

     

    JSONFragmenter(JSONQueryFactory): The JSON text could not be parsed as 'GEOJSON', parsing as plain JSON instead
    I suspect that a specific build of FME won't perform the automatic reinterpretation on the 'Explode as Format'. Could you check this? @RylanAtSafe
    @takashi - Testing with Build 15575 Win64 and 'Explode as Format' set to GEOJSON displays the warning, but the translation is successful and the fill-opacity is correctly exposed and populated with value.

     

    0684Q00000ArNDGQA3.png


    When you set GEOJSON to the 'Explode as Format ' parameter, the JSONFragmenter attempts to fragment the source JSON document into individual Features

     

    {
       "geometry" : {
          "type" : "Polygon",
          "coordinates" : o ... ]
       },
       "type" : "Feature",
       "properties" : {
          "stroke-opacity" : 0.9,
          "fill-opacity" : 0.9,
          "hail_size_in_int" : 0.5,
          "hail_size_in" : "0.5-0.9 inches",
          "stroke-width" : 0,
          "fill" : "#FFFFC0"
       }
    }
    and then flatten the "properties" object. In this case, strictly saying, the JSON query should be this one which fragments the source JSON document into individual GeoJSON Features.

     

    jsonÂ"features"]
  • However, even if you have set GEOJSON to the 'Explode as Format' parameter, FME seems to treat the parameter as JSON when the JSON query is not correct to fragment the source document into GeoJSON Features. Result, this query could also return the expected result.

     

    json "features"]
  • s"properties"]
  •  Probably you find this warning message on the Translation Log.

     

    JSONFragmenter(JSONQueryFactory): The JSON text could not be parsed as 'GEOJSON', parsing as plain JSON instead
    I suspect that a specific build of FME won't perform the automatic reinterpretation on the 'Explode as Format'. Could you check this? @RylanAtSafe
    @RylanAtSafe, from your testing result, the build 15575 too seems to treat the 'Explode as Format' with the same manner as other versions.

     

    @fmeuser_gc, really strange if the JSON query they suggested doesn't work for your case. If the problem has not been resolved yet, I would recommend you to attach your workspace that reproduces the problem to your comment here, or send that to Safe support.
    @RylanAtSafe, from your testing result, the build 15575 too seems to treat the 'Explode as Format' with the same manner as other versions.

     

    @fmeuser_gc, really strange if the JSON query they suggested doesn't work for your case. If the problem has not been resolved yet, I would recommend you to attach your workspace that reproduces the problem to your comment here, or send that to Safe support.
    @RylanAtSafe, @takashi, @david_r

     

    Attached the workspace. I've used same queries provided by you, but get blank attribute values.

     

     

    jsonfragment-test.fmw

    Hi @fmeuser_gc, the response body from the HTTPCaller in your attached workspace (jsonfragment-test.fmw) looks like this.

    {
       "code" : 200,
       "status" : "success",
       "data" : {
          "type" : "FeatureCollection",
          "features" : e
             {
                "geometry" : {
                   "type" : "Polygon",
                   "coordinates" : Â
    ...

    It's a JSON document which contains a GeoJSON "FeatureCollection" object as a member called "data". The structure is different from the GeoJSON document that you have pasted in your first question. That's the reason why nobody was able to find a correct JSON query.

    If you want to extract individual GeoJSON features from the "data" object with the JSONFragmenter (Explode as Format: GEOJSON), you have to specify the correct path with the JSON query. Try this.

    jsonÂ"data"]Â"features"]

  • Hi @fmeuser_gc, the response body from the HTTPCaller in your attached workspace (jsonfragment-test.fmw) looks like this.

    {
       "code" : 200,
       "status" : "success",
       "data" : {
          "type" : "FeatureCollection",
          "features" : e
             {
                "geometry" : {
                   "type" : "Polygon",
                   "coordinates" : Â
    ...

    It's a JSON document which contains a GeoJSON "FeatureCollection" object as a member called "data". The structure is different from the GeoJSON document that you have pasted in your first question. That's the reason why nobody was able to find a correct JSON query.

    If you want to extract individual GeoJSON features from the "data" object with the JSONFragmenter (Explode as Format: GEOJSON), you have to specify the correct path with the JSON query. Try this.

    jsonÂ"data"]Â"features"]
  • Thank You everyone your your replies. It works now after @takashi identified an issue.

     


    Reply