fix: Add example to README
This commit is contained in:
42
README.md
42
README.md
@@ -7,3 +7,45 @@
|
||||
## Build
|
||||
|
||||
`dotnet run Bundle`
|
||||
|
||||
## Example usage
|
||||
|
||||
```fsharp
|
||||
let geoJson = """
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [102.0, 0.5]
|
||||
},
|
||||
"properties": {
|
||||
"prop0": "value0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
|
||||
[100.0, 1.0], [100.0, 0.0]
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
"""
|
||||
|
||||
let readJson () =
|
||||
let result = FeatureCollection.Decode geoJson
|
||||
match result with
|
||||
| Ok json -> printfn $"%A{json.Features}"
|
||||
| Error e -> printfn $"decode failed: {e}"
|
||||
|
||||
let encodeJson (json: FeatureCollection) = json.Encode ()
|
||||
```
|
||||
Reference in New Issue
Block a user