Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Improved slice unmarshalling support#129

Closed
blakepettersson wants to merge 1 commit intogoogle:masterfrom
blakepettersson:improved-slice-unmarshaling-support
Closed

Improved slice unmarshalling support#129
blakepettersson wants to merge 1 commit intogoogle:masterfrom
blakepettersson:improved-slice-unmarshaling-support

Conversation

@blakepettersson
Copy link
Copy Markdown

  • All integer slice types are supported

JSON number arrays can be unmarshaled as int, int8, int16, int32
and int64 slices, as well as uint, uint16, uint32 and
uint64 slices, as well as slices that are pointers to the
aforementioned types.

In the case of uint8 slices, the assumption is that it is unmarshaled
from a base64 encoded string, since that is how a []uint8 is
marshaled with json.Marshal.

  • JSON arrays can also be unmarshaled as float32 and float64 slices,
    as well as the pointer variants of those types.

  • time.Time slices are also supported, both values and pointers.

This is similar to #73, but covers more types.

@googlebot
Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers
  • Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
  • The email used to register you as an authorized contributor must also be attached to your GitHub account.

@blakepettersson
Copy link
Copy Markdown
Author

I signed it!

* All integer slice types are supported

JSON number arrays can be unmarshaled as `int`, `int8`, `int16`, `int32`
and `int64` slices, as well as `uint`, `uint16`, `uint32` and
`uint64` slices, as well as slices that are pointers to the
aforementioned types.

In the case of `uint8` slices, the assumption is that it is unmarshaled
from a base64 encoded string, since that is how a `[]uint8` is
marshaled with `json.Marshal`.

* JSON arrays can also be unmarshaled as `float32` and `float64` slices,
as well as the pointer variants of those types.

* `time.Time` slices are also supported, both values and pointers.
@blakepettersson blakepettersson force-pushed the improved-slice-unmarshaling-support branch from e2c956a to 8e3499c Compare March 11, 2018 18:31
@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

tianzhou added a commit to bytebase/bytebase that referenced this pull request Jun 20, 2021
…onapi doesn’t support unmarshalling int slice

BTW, there is an outstanding PR to support this: google/jsonapi#129
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants