'key' objects dont marshal to json well
Jeromy committed
Jun 4, 2015 at 16:33 UTC
b4f55d337a70c581184daa80e2ab3ad28210a9e8
1 file changed
+7
-7
core/commands/object.go
+7
-7
@@ -436,7 +436,7 @@ resulting object hash.
436
cmds.StringArg("command", true, false, "the operation to perform"),
437
cmds.StringArg("args", true, true, "extra arguments").EnableStdin(),
438
},
439
- Type: key.Key(""),
439
+ Type: Object{},
440
Run: func(req cmds.Request, res cmds.Response) {
441
nd, err := req.Context().GetNode()
442
if err != nil {
@@ -468,28 +468,28 @@ resulting object hash.
468
res.SetError(err, cmds.ErrNormal)
469
return
470
}
471
- res.SetOutput(k)
471
+ res.SetOutput(&Object{Hash: k.B58String()})
472
case "rm-link":
473
k, err := rmLinkCaller(req, rnode)
474
if err != nil {
475
res.SetError(err, cmds.ErrNormal)
476
return
477
}
478
- res.SetOutput(k)
478
+ res.SetOutput(&Object{Hash: k.B58String()})
479
case "set-data":
480
k, err := setDataCaller(req, rnode)
481
if err != nil {
482
res.SetError(err, cmds.ErrNormal)
483
return
484
}
485
- res.SetOutput(k)
485
+ res.SetOutput(&Object{Hash: k.B58String()})
486
case "append-data":
487
k, err := appendDataCaller(req, rnode)
488
if err != nil {
489
res.SetError(err, cmds.ErrNormal)
490
return
491
}
492
- res.SetOutput(k)
492
+ res.SetOutput(&Object{Hash: k.B58String()})
493
default:
494
res.SetError(fmt.Errorf("unrecognized subcommand"), cmds.ErrNormal)
495
return
@@ -497,12 +497,12 @@ resulting object hash.
497
},
498
Marshalers: cmds.MarshalerMap{
499
cmds.Text: func(res cmds.Response) (io.Reader, error) {
500
- k, ok := res.Output().(key.Key)
500
+ o, ok := res.Output().(*Object)
501
if !ok {
502
return nil, u.ErrCast()
503
}
504
505
- return strings.NewReader(k.B58String() + "\n"), nil
505
+ return strings.NewReader(o.Hash + "\n"), nil
506
},
507
},
508
}