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

There is a case where json-iterator is not 100% compatible with encoding/json #164

@pamburus

Description

@pamburus

Here is an example which works with standard encoding/json, but does not work with json-iterator

package main

import (
	"fmt"

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

// TestData is for tests
type TestData struct {
	Name string `json:"name"`
}

func main() {
	var data TestData
	data.Name = "value"

	s, err := jsoniter.Marshal(data)
	if err != nil {
		panic(err)
	}

	var result TestData
	out := interface{}(&result)
	err = jsoniter.Unmarshal(s, &out)
	if err != nil {
		panic(err)
	}

	fmt.Println(result)
}

Output:
{}

See version with encoding/json: https://play.golang.org/p/PHmDZrF1Fy
Output:
{value}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions