etcdctl: print full json response for Get

Otherwise parsing get/txn output with json is somewhat complicated
because in some cases there's a json message and sometimes not.
Likewise, a get on an absent key has to return the current revision for
some algorithms to work.
This commit is contained in:
Anthony Romano 2016-04-19 20:53:00 -07:00
parent 0c40f4a7e3
commit d2a58cbb0a
3 changed files with 4 additions and 8 deletions

View File

@ -100,7 +100,7 @@ func getFormatTest(cx ctlCtx) {
wstr string
}{
{"simple", "abc"},
{"json", "\"key\":\"YWJj\""},
{"json", `"kvs":[{"key":"YWJj"`},
{"protobuf", "\x17\b\x93\xe7\xf6\x93\xd4ņ\xe14\x10\xed"},
}

View File

@ -80,7 +80,7 @@ TODO: add consistency, from, prefix
##### JSON reply
The JSON encoding of the [RPC message][etcdrpc] for a key-value pair for each fetched key-value.
The JSON encoding of the [RPC response][etcdrpc] for the GET's Range request.
##### Protobuf reply

View File

@ -163,12 +163,8 @@ func (s *simplePrinter) DBStatus(ds dbstatus) {
type jsonPrinter struct{}
func (p *jsonPrinter) Del(r v3.DeleteResponse) { printJSON(r) }
func (p *jsonPrinter) Get(r v3.GetResponse) {
for _, kv := range r.Kvs {
printJSON(kv)
}
}
func (p *jsonPrinter) Del(r v3.DeleteResponse) { printJSON(r) }
func (p *jsonPrinter) Get(r v3.GetResponse) { printJSON(r) }
func (p *jsonPrinter) Put(r v3.PutResponse) { printJSON(r) }
func (p *jsonPrinter) Txn(r v3.TxnResponse) { printJSON(r) }
func (p *jsonPrinter) Watch(r v3.WatchResponse) { printJSON(r) }