Json vec substructs on one line

I have been searching, but could not find.
Is it possible to change the serde json output for small substructs (in a vec of the owner) from this:

{
  "title": "Just dig!",
  "tiles": [
    {
      "pack_id": 0,
      "set_id": 0,
      "tile_id": 3,
      "x": 646,
      "y": 78,
      "drawing": {}
    },
    {
      "pack_id": 0,
      "set_id": 0,
      "tile_id": 3,
      "x": 729,
      "y": 79,
      "drawing": {}
    }
  ]
}

into this?

{
  "title": "Just dig!",
  "tiles": [
    { "pack_id": 0, "set_id": 0, "tile_id": 3, "x": 646, "y": 78, "drawing": {} },
    { "pack_id": 0, "set_id": 0, "tile_id": 3, "x": 729, "y": 79, "drawing": {} }
  ]
}

No, there is only to_string and to_string_pretty. The latter formats the resulting JSON as your first example, the former packed as:

{"tiles":[{"drawing":{},"pack_id":0,"set_id":0,"tile_id":3,"x":646,"y":78},{"drawing":{},"pack_id":0,"set_id":0,"tile_id":3,"x":729,"y":79}],"title":"Just dig!"}

I guess you could implement your own Formatter to implement your desired output.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.