ijl / orjson

Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy
Apache License 2.0
6.06k stars 209 forks source link

Enh proposal: deserialize without exactly knowing the target class #503

Closed gri38 closed 1 month ago

gri38 commented 2 months ago

Hello.

First of all: congratulation for your awesome, and so efficient, project.

I "come from (as a user)" jsons, but I'm trying to switch to your project which handle better numpy types, and seems to be more efficient.

One feature I'm missing is the capability to serialize types with type information, and being able to deserialize to the type without knowing the target type.

It's documented here in jsons.

The serialization with verbose=True gives something like that:

{
  "boundingBox": [
    577.7325568725256,
    622.0887652678679,
    638.2674431274744,
    652.3221671302455
  ],
  "-meta": {
    "classes": {
      "/": "my.package.Metadata"
    },
    "dump_time": "2024-06-18T07:41:40Z"
  }
}

We can discuss the use cases if you want.

Thanks.