egg-mode-rs / egg-mode

a twitter api crate for rust
https://crates.io/crates/egg-mode
Mozilla Public License 2.0
372 stars 65 forks source link

Fix bounding_box serializer #116

Closed kenkoooo closed 3 years ago

kenkoooo commented 3 years ago

According to the API document, the type of the coordinates field in the bounding box object is "Array of Array of Array of Float" like the following: https://developer.twitter.com/en/docs/twitter-api/premium/data-dictionary/object-model/geo

{
  "coordinates": [[
      [
        -74.026675,
        40.683935
      ],
      [
        -74.026675,
        40.877483
      ],
      [
        -73.910408,
        40.877483
      ],
      [
        -73.910408,
        40.3935
      ]
    ]]
}

We can parse it correctly, but we can not serialize it to JSON correctly. The coordinates value of a serialized JSON object will be "Array of Array of Float" like the following:

{
  "coordinates": [
      [
        -74.026675,
        40.683935
      ],
      [
        -74.026675,
        40.877483
      ],
      [
        -73.910408,
        40.877483
      ],
      [
        -73.910408,
        40.3935
      ]
    ]
}

In this PR, I fixed the serializer and added a test for it.

adwhit commented 3 years ago

Thanks, LGTM

kenkoooo commented 3 years ago

Thank you for the review!