Skip to content

Set with index overrides always first position of the array  #267

Open
@fedeizzo

Description

@fedeizzo

What is the problem

If I try to call Set on an array jsonparser always replaces the first element of the array, regardless of the index passed

How to replicate

	myJSON := []byte(`{}`)
	myJSON, _ = jsonparser.Set(myJSON, []byte("1"), "test", "[0]")
	myJSON, _ = jsonparser.Set(myJSON, []byte("2"), "test", "[1]")
	myJSON, _ = jsonparser.Set(myJSON, []byte("3"), "test", "[2]")

	fmt.Println(string(myJSON))

Expected output

{"test":[1,2,3]}

Actual output

{"test":[3]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions