Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed dumps to json, got invalid type error #36

Open
sbant opened this issue Dec 22, 2020 · 0 comments
Open

Failed dumps to json, got invalid type error #36

sbant opened this issue Dec 22, 2020 · 0 comments

Comments

@sbant
Copy link

sbant commented Dec 22, 2020

I'm using python 3.9

The class:

@dataclass
class TcUiMsg:
    Fairvalue: Optional[dict[str, Fv]] = None

Fv is an object.

use perde.json.dumps to dump

out_txt = perde.json.dumps(msg)

got error:
Exception has occurred: TypeError (note: full exception trace is shown but execution is paused at: _run_module_as_main)
invalid argument: cannot get generic type information: typing.Optional[dict]: cannot get generic type information: dict[str, None]: invalid value type in dict: None is not a type

the object can dumps with orjson (orjson dumps to bytes ...)

out_bytes = orjson.dumps(msg)
out_txt = out_bytes.decode("utf-8")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant