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

JSON iter doesn't work properly with nil RawMessage #469

Open
mjnovice opened this issue Jun 24, 2020 · 3 comments
Open

JSON iter doesn't work properly with nil RawMessage #469

mjnovice opened this issue Jun 24, 2020 · 3 comments

Comments

@mjnovice
Copy link

package main

import (
	"encoding/json"
	"fmt"

	jsoniter "github.com/json-iterator/go"
)

func main() {
	type A struct {
		Rm jsoniter.RawMessage
	}

	a := A{}
	b, e := jsoniter.Marshal(a)
	fmt.Println("jsoniter: ",b, e)
	e = jsoniter.Unmarshal(b, &a)
	fmt.Println("jsoniter: ",e)

	b, e = json.Marshal(a)
	fmt.Println("json: ",b, e)
	e = json.Unmarshal(b, &a)
	fmt.Println("json: ",e)
}

https://play.golang.org/p/RoBEyZNxk-R

@funny-falcon
Copy link

Fully symmetric comparison validates issue:
https://play.golang.org/p/ydVcBDQsF5l

AllenX2018 added a commit that referenced this issue Jul 21, 2020
@NOMORECOFFEE
Copy link

NOMORECOFFEE commented Sep 21, 2021

Hello. It's brake behavior to unmarshal null value into RawMessage

https://play.golang.org/p/xDrMSSKyisZ

zhenzou pushed a commit to zhenzou/jsoniter that referenced this issue Feb 2, 2022
@tiit-clarifai
Copy link

@AllenX2018 As mentioned by the preceding commenter, the changes introduced in 5bce16d broke compatibility with unmarshaling of null into a RawMessage: the result is a nil byte slice, but the standard library would store the bytes null instead.

Would it be possible to address this issue?

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

4 participants