Skip to content

Add macros to ease the creation of structures #192

@frewsxcv

Description

@frewsxcv

(copied from discord)

what do people think about adding macros in the geojson crate to ease creation?

let feature = geojson::feature! {
   geometry: geojson::point![1., 1.],
   properties: {
      foo: "bar",
   },
};

versus

let properties = HashMap::<String, serde_json::JsonValue>::new():
properties.insert("foo".to_string(), "bar".to_string());
let feature = geojson::Feature {
   geometry: Some(geojson::Geometry::new(
      geojson::Value::Point(vec![1., 1.,]),
   )),
   properties: Some(properties),
   ...Default::default(),
};

not the exact syntax necessarily. just think it would be great to have an easier way to construct the structures

it'd be really slick if the body of the macro was identical syntax to geojson

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions