Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export serde_json::Map #185

Closed
frewsxcv opened this issue May 1, 2022 · 0 comments · Fixed by #191
Closed

Re-export serde_json::Map #185

frewsxcv opened this issue May 1, 2022 · 0 comments · Fixed by #191

Comments

@frewsxcv
Copy link
Member

frewsxcv commented May 1, 2022

So users don't need to add serde_json as a dependency to construct a Feature

bors bot added a commit that referenced this issue May 27, 2022
191: Reexport `JsonObject` and `JsonValue` from `serde_json`. r=michaelkirk a=frewsxcv

- [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md).
- [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users.
---

Prior to this commit, users would need to add `serde_json` as a
dependency in order to construct a `Feature` with properties.

Fixes #185

Before:

```rust
use geojson::{Feature, GeoJson, Geometry, Value};
use serde_json::{Map, to_value};

let geometry = Geometry::new(
    Value::Point(vec![-120.66029,35.2812])
);

let mut properties = Map::new();
properties.insert(
    String::from("name"),
    to_value("Firestone Grill").unwrap(),
);

let geojson = GeoJson::Feature(Feature {
    bbox: None,
    geometry: Some(geometry),
    id: None,
    properties: Some(properties),
    foreign_members: None,
});
```

After:

```rust
use geojson::{Feature, GeoJson, Geometry, Value, JsonObject, JsonValue};

let geometry = Geometry::new(
    Value::Point(vec![-120.66029,35.2812])
);

let mut properties = JsonObject::new();
properties.insert(
    String::from("name"),
    JsonValue::from("Firestone Grill"),
);

let geojson = GeoJson::Feature(Feature {
    bbox: None,
    geometry: Some(geometry),
    id: None,
    properties: Some(properties),
    foreign_members: None,
});
```

Co-authored-by: Corey Farwell <[email protected]>
@bors bors bot closed this as completed in e2181c4 May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant