Skip to content

Support decoding JSON from a str object - #229

Merged
jcrist merged 1 commit into
mainfrom
support-decode-json-from-str
Dec 7, 2022
Merged

Support decoding JSON from a str object#229
jcrist merged 1 commit into
mainfrom
support-decode-json-from-str

Conversation

@jcrist

@jcrist jcrist commented Dec 7, 2022

Copy link
Copy Markdown
Member

This adds support for decoding JSON from str objects, rather than just bytes (or bytes-like) objects.

For peak performance it's still recommended to decode from a bytes-like object, but native support for decoding from str types is faster and more ergonomic than forcing the user to call str_message.encode("utf-8") themselves.

This also adds support for formatting str JSON messages using msgspec.json.format. If a str is passed in the return type is a str, otherwise the return type is bytes.

This adds support for decoding JSON from `str` objects, rather than just
`bytes` (or bytes-like) objects.

For peak performance it's still recommended to decode from a bytes-like
object, but native support for decoding from str types is faster than
forcing the user to call `str_message.encode("utf-8")` themselves.

This also adds support for formatting str JSON messages using
`msgspec.json.format`. If a str is passed in the return type is a str,
otherwise the return type is `bytes`.
@jcrist
jcrist merged commit 48e11b7 into main Dec 7, 2022
@jcrist
jcrist deleted the support-decode-json-from-str branch December 7, 2022 02:46
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

Successfully merging this pull request may close these issues.

1 participant