Skip to main content

I have a JSON file from waze that I am trying to read.

I am using the JSON (JavaScript Object Notation) reader.

There are three schema; alerts, irregularities and jams

I can read alerts okay with this query

json["alerts"]

  • Flatten Nested JSON values into Attributes = Yes

    Read Entire Feature as JSON Fragment = No

    which reads 433 alerts, each with a location.x and location.y which allows me to built a point object (Vertex) for each feature.

    But I am struggling with the irregularities and jams.

    The irregularities have a line object which obviously does not convert into two neat columns.

    How do I read the line object?

    I have attached the json file here

  • Hi @nicholas

    There are a few options to create geometry from the line array. One option is to create a valid geometry encoding (eg. GeoJSON, WKT, etc) from the line array and use a GeometryReplacer to recreate the geometry. In the example, I used a JSONTemplater to create GeoJSON as it allows for easy recursion through each element of the line array. However, it does depend on understanding XQuery/JSONiq.

     

    Another option is to use a ListExploder on the line list attribute, then a VertexCreator to create points from the x and y attributes before using a LineBuilder to create lines from the vertices (group by 'id' or 'uuid' depending on the feature type). Note that if you are working with a large file, exploding the vertices may lead to decreased performance due to the increased number of features.


    Reply