Skip to content
Snippets Groups Projects
Unverified Commit a61cafcf authored by Ashish Negi's avatar Ashish Negi
Browse files

String quote all uids in json output form : fix #608

parent f8f07de1
No related branches found
No related tags found
No related merge requests found
......@@ -470,8 +470,8 @@ func (sg *SubGraph) ToFastJSON(l *Latency, w io.Writer, allocIds map[string]stri
if sg.Params.isDebug {
sl := seedNode.New("serverLatency").(*fastJsonNode)
for k, v := range l.ToMap() {
val := types.ValueForType(types.BinaryID)
val.Value = []byte(fmt.Sprintf("%q", v))
val := types.ValueForType(types.StringID)
val.Value = v
sl.AddValue(k, val)
}
n.AddMapChild("server_latency", sl, false)
......@@ -480,8 +480,8 @@ func (sg *SubGraph) ToFastJSON(l *Latency, w io.Writer, allocIds map[string]stri
if allocIds != nil && len(allocIds) > 0 {
sl := seedNode.New("uids").(*fastJsonNode)
for k, v := range allocIds {
val := types.ValueForType(types.BinaryID)
val.Value = []byte(v)
val := types.ValueForType(types.StringID)
val.Value = v
sl.AddValue(k, val)
}
n.AddMapChild("uids", sl, false)
......
......@@ -273,7 +273,7 @@ func TestReturnUids(t *testing.T) {
require.NoError(t, ToJson(&l, sgl, &buf, mp))
js := buf.String()
require.JSONEq(t,
`{"uids":{"a":123},"me":[{"_uid_":"0x1","alive":true,"friend":[{"_uid_":"0x17","name":"Rick Grimes"},{"_uid_":"0x18","name":"Glenn Rhee"},{"_uid_":"0x19","name":"Daryl Dixon"},{"_uid_":"0x1f","name":"Andrea"},{"_uid_":"0x65"}],"gender":"female","name":"Michonne"}]}`,
`{"uids":{"a":"123"},"me":[{"_uid_":"0x1","alive":true,"friend":[{"_uid_":"0x17","name":"Rick Grimes"},{"_uid_":"0x18","name":"Glenn Rhee"},{"_uid_":"0x19","name":"Daryl Dixon"},{"_uid_":"0x1f","name":"Andrea"},{"_uid_":"0x65"}],"gender":"female","name":"Michonne"}]}`,
js)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment