"codeModel" is leaked when transforming `CapturedStructure` into JSON.

So, I have been playing with the new version of RoomPlan (it is pretty awesome!). However, I found this bug... or, I think it is a bug:

When I get the JSON, I get the following field, for each room:

{
        "rooms": [
            {
                "story": 1,
                "floors": [
                    ...
                ],
                "coreModel": "xPNhmdphlnynwusRL92NgUYKht... 

...
...

This is kind of annoting, as this is quite a big field. With the coreModel, the file is 828kB. When I remove it, it is 267kB.

Post not yet marked as solved Up vote post of germolinal Down vote post of germolinal
493 views

Replies

hi germolinal, dumb question - how did you get the object serialized to json? Im looking at the api docs, but dont see anything obvious. thanks!

  • Hey @Brent185 ,

    CapturedStructure conforms to Codable (i.e., Encodable Decodable), meaning that it can be transformed into JSON as follows:

    let encoder = JSONEncoder() do { let data = try encoder.encode(data) let model = String(data: data, encoding: .utf8)! }catch { msg = "Could not encode" // ... do something about it }
Add a Comment