Skip to content

move fails with "missing value" if from is "" #192

@lucastheisen

Description

@lucastheisen

According to the JSON Pointer RFC 6901:

The following JSON strings evaluate to the accompanying values:

""           // the whole document

But using that as a from results in a missing value error.

Adding this test will demonstrate the bug:

func TestMoveFromRoot(t *testing.T) {
	expected := `{"baz":{"foo":"bar"}}`
	res, err := applyPatch(`{"foo":"bar"}`, `[{"op":"move","from":"","path":"/baz"}]`)
	if err != nil {
		t.Errorf("unexpected error: %+v", err)
	} else if res != expected {
		t.Errorf("expected:\n%s\ngot:\n%s", expected, res)
	}
}

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