According to the JSON Pointer RFC 6901:
The following JSON strings evaluate to the accompanying values:
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)
}
}