Skip to content

Instantly share code, notes, and snippets.

@gzysk8
Created November 14, 2023 22:45
Show Gist options
  • Save gzysk8/e47b71db697c400fd91d5c7ea231de4c to your computer and use it in GitHub Desktop.
Save gzysk8/e47b71db697c400fd91d5c7ea231de4c to your computer and use it in GitHub Desktop.
// Get just data under the value key on the consumed message
const vehicle_value = message.value.value;
// Flatten the nested JSON
const flattenedVehicle = {
vehicle_id: vehicle_value.vehicle_id,
location_latitude: vehicle_value.location.latitude,
location_longitude: vehicle_value.location.longitude,
ts: Date.now(),
destination_latitude: vehicle_value.destination.latitude,
destination_longitude: vehicle_value.destination.longitude,
distanceRemaining: vehicle_value.distanceRemaining,
ETA: vehicle_value.ETA
};
return flattenedVehicle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment