diff --git a/demo/bgp/testdata/bgp-ietf.json b/demo/bgp/testdata/bgp-ietf.json index 66fbc4db7..fedb135a1 100644 --- a/demo/bgp/testdata/bgp-ietf.json +++ b/demo/bgp/testdata/bgp-ietf.json @@ -1,11 +1,11 @@ { - "global": { + "openconfig-network-instance:global": { "config": { "as": 15169, "router-id": "192.0.2.42" } }, - "neighbors": { + "openconfig-network-instance:neighbors": { "neighbor": [ { "config": { diff --git a/ygot/render.go b/ygot/render.go index 9f516adab..e69bb03d9 100644 --- a/ygot/render.go +++ b/ygot/render.go @@ -951,7 +951,7 @@ func (*RFC7951JSONConfig) IsMarshal7951Arg() {} // to JSON described by RFC7951. The supplied args control options corresponding // to the method by which JSON is marshalled. func ConstructIETFJSON(s ValidatedGoStruct, args *RFC7951JSONConfig) (map[string]interface{}, error) { - return structJSON(s, s.ΛBelongingModule(), jsonOutputConfig{ + return structJSON(s, "", jsonOutputConfig{ jType: RFC7951, rfc7951Config: args, }) @@ -1000,11 +1000,7 @@ func Marshal7951(d interface{}, args ...Marshal7951Arg) ([]byte, error) { indent = string(v) } } - var parentMod string - if s, ok := d.(ValidatedGoStruct); ok { - parentMod = s.ΛBelongingModule() - } - j, err := jsonValue(reflect.ValueOf(d), parentMod, jsonOutputConfig{ + j, err := jsonValue(reflect.ValueOf(d), "", jsonOutputConfig{ jType: RFC7951, rfc7951Config: rfcCfg, }) diff --git a/ygot/render_test.go b/ygot/render_test.go index 25c2af86e..4307dfec7 100644 --- a/ygot/render_test.go +++ b/ygot/render_test.go @@ -2873,15 +2873,15 @@ func TestConstructJSON(t *testing.T) { }, inAppendMod: true, wantIETF: map[string]interface{}{ - "f1": "foo", - "config": map[string]interface{}{ + "f1mod:f1": "foo", + "f1mod:config": map[string]interface{}{ "f2mod:f6": "mat", }, "f2mod:config": map[string]interface{}{ "f2": "bar", "f3mod:f7": "bat", }, - "f3": map[string]interface{}{ + "f1mod:f3": map[string]interface{}{ "f42mod:config": map[string]interface{}{ "f4": "baz", }, @@ -3895,7 +3895,7 @@ func TestEncodeTypedValue(t *testing.T) { }, inEnc: gnmipb.Encoding_JSON_IETF, want: &gnmipb.TypedValue{Value: &gnmipb.TypedValue_JsonIetfVal{[]byte(`{ - "f1": "hello" + "f1mod:f1": "hello" }`)}}, }, { name: "struct val - ietf json different module", @@ -4201,7 +4201,7 @@ func TestMarshal7951(t *testing.T) { inArgs: []Marshal7951Arg{ &RFC7951JSONConfig{AppendModuleName: true}, }, - want: `{"f1":"hello"}`, + want: `{"f1mod:f1":"hello"}`, }, { desc: "complex children with module name prepend request", in: &ietfRenderExample{ @@ -4216,7 +4216,7 @@ func TestMarshal7951(t *testing.T) { JSONIndent(" "), }, want: `{ - "enum-list": [ + "f1mod:enum-list": [ { "config": { "key": "foo:VAL_ONE" @@ -4224,14 +4224,14 @@ func TestMarshal7951(t *testing.T) { "key": "foo:VAL_ONE" } ], - "f2mod:config": { - "f2": "bar" - }, - "mixed-list": [ + "f1mod:mixed-list": [ "foo:VAL_ONE", "test", 42 - ] + ], + "f2mod:config": { + "f2": "bar" + } }`, }, { desc: "complex children with PrependModuleNameIdentityref=true", @@ -4278,7 +4278,7 @@ func TestMarshal7951(t *testing.T) { JSONIndent(" "), }, want: `{ - "enum-list": [ + "f1mod:enum-list": [ { "config": { "key": "foo:VAL_ONE" @@ -4286,14 +4286,14 @@ func TestMarshal7951(t *testing.T) { "key": "foo:VAL_ONE" } ], - "f2mod:config": { - "f2": "bar" - }, - "mixed-list": [ + "f1mod:mixed-list": [ "foo:VAL_ONE", "test", 42 - ] + ], + "f2mod:config": { + "f2": "bar" + } }`, }}