Skip to main content
Question

How to read a JSON file from waze

  • November 23, 2022
  • 3 replies
  • 149 views

nicholas
Contributor
Forum|alt.badge.img+13

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

3 replies

debbiatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • November 27, 2022

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.


cschra-c
Contributor
Forum|alt.badge.img
  • Contributor
  • May 7, 2025

Thanks for sharing that workbench!

I’m trying to update the workbench so that it calls the Waze API, however, I am encountering an issue where it doesn’t see a line{} attribute. Instead it sees a line attribute. If I update the ROOT Template Expression in the JSONTemplater transformer with line instead of line{}, it just returns { "type" : "linestring", "coordinates" : [  ] }.

Please help :)


desiree_at_safe
Safer
Forum|alt.badge.img+11

 Hi ​@cschra-c

I’d encourage creating a new post to get more visibility and community attention on your issue!

Also, details like a sample workspace template (alternatively, screenshots also work to avoid sending sensitive info like tokens or keys), the API endpoint and API response, or links to this or other relevant posts can be really helpful for other community members to better understand and help with your specific case.

These are optional, but encouraged🙂


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