@ -0,0 +1,53 @@ | |||
// nolint: dupl | |||
package merkle | |||
import ( | |||
"bytes" | |||
"encoding/json" | |||
"github.com/gogo/protobuf/jsonpb" | |||
) | |||
//--------------------------------------------------------------------------- | |||
// override JSON marshalling so we emit defaults (ie. disable omitempty) | |||
var ( | |||
jsonpbMarshaller = jsonpb.Marshaler{ | |||
EnumsAsInts: true, | |||
EmitDefaults: true, | |||
} | |||
jsonpbUnmarshaller = jsonpb.Unmarshaler{} | |||
) | |||
func (r *ProofOp) MarshalJSON() ([]byte, error) { | |||
s, err := jsonpbMarshaller.MarshalToString(r) | |||
return []byte(s), err | |||
} | |||
func (r *ProofOp) UnmarshalJSON(b []byte) error { | |||
reader := bytes.NewBuffer(b) | |||
return jsonpbUnmarshaller.Unmarshal(reader, r) | |||
} | |||
func (r *Proof) MarshalJSON() ([]byte, error) { | |||
s, err := jsonpbMarshaller.MarshalToString(r) | |||
return []byte(s), err | |||
} | |||
func (r *Proof) UnmarshalJSON(b []byte) error { | |||
reader := bytes.NewBuffer(b) | |||
return jsonpbUnmarshaller.Unmarshal(reader, r) | |||
} | |||
// Some compile time assertions to ensure we don't | |||
// have accidental runtime surprises later on. | |||
// jsonEncodingRoundTripper ensures that asserted | |||
// interfaces implement both MarshalJSON and UnmarshalJSON | |||
type jsonRoundTripper interface { | |||
json.Marshaler | |||
json.Unmarshaler | |||
} | |||
var _ jsonRoundTripper = (*ProofOp)(nil) | |||
var _ jsonRoundTripper = (*Proof)(nil) |
@ -0,0 +1,54 @@ | |||
// nolint: dupl | |||
// dupl is reading this as the same file as crypto/merkle/result.go | |||
package common | |||
import ( | |||
"bytes" | |||
"encoding/json" | |||
"github.com/gogo/protobuf/jsonpb" | |||
) | |||
//--------------------------------------------------------------------------- | |||
// override JSON marshalling so we emit defaults (ie. disable omitempty) | |||
var ( | |||
jsonpbMarshaller = jsonpb.Marshaler{ | |||
EnumsAsInts: true, | |||
EmitDefaults: true, | |||
} | |||
jsonpbUnmarshaller = jsonpb.Unmarshaler{} | |||
) | |||
func (r *KVPair) MarshalJSON() ([]byte, error) { | |||
s, err := jsonpbMarshaller.MarshalToString(r) | |||
return []byte(s), err | |||
} | |||
func (r *KVPair) UnmarshalJSON(b []byte) error { | |||
reader := bytes.NewBuffer(b) | |||
return jsonpbUnmarshaller.Unmarshal(reader, r) | |||
} | |||
func (r *KI64Pair) MarshalJSON() ([]byte, error) { | |||
s, err := jsonpbMarshaller.MarshalToString(r) | |||
return []byte(s), err | |||
} | |||
func (r *KI64Pair) UnmarshalJSON(b []byte) error { | |||
reader := bytes.NewBuffer(b) | |||
return jsonpbUnmarshaller.Unmarshal(reader, r) | |||
} | |||
// Some compile time assertions to ensure we don't | |||
// have accidental runtime surprises later on. | |||
// jsonEncodingRoundTripper ensures that asserted | |||
// interfaces implement both MarshalJSON and UnmarshalJSON | |||
type jsonRoundTripper interface { | |||
json.Marshaler | |||
json.Unmarshaler | |||
} | |||
var _ jsonRoundTripper = (*KVPair)(nil) | |||
var _ jsonRoundTripper = (*KI64Pair)(nil) |
@ -1,13 +0,0 @@ | |||
--- | |||
title: RPC Reference | |||
language_tabs: # must be one of https://git.io/vQNgJ | |||
- shell | |||
- go | |||
toc_footers: | |||
- <a href='https://tendermint.com/'>Tendermint</a> | |||
- <a href='https://github.com/lord/slate'>Documentation Powered by Slate</a> | |||
search: true | |||
--- |
@ -0,0 +1,74 @@ | |||
package proto3 | |||
import ( | |||
"bytes" | |||
"encoding/json" | |||
"github.com/gogo/protobuf/jsonpb" | |||
) | |||
//--------------------------------------------------------------------------- | |||
// override JSON marshalling so we emit defaults (ie. disable omitempty) | |||
var ( | |||
jsonpbMarshaller = jsonpb.Marshaler{ | |||
EnumsAsInts: true, | |||
EmitDefaults: true, | |||
} | |||
jsonpbUnmarshaller = jsonpb.Unmarshaler{} | |||
) | |||
func (r *PartSetHeader) MarshalJSON() ([]byte, error) { | |||
s, err := jsonpbMarshaller.MarshalToString(r) | |||
return []byte(s), err | |||
} | |||
func (r *PartSetHeader) UnmarshalJSON(b []byte) error { | |||
reader := bytes.NewBuffer(b) | |||
return jsonpbUnmarshaller.Unmarshal(reader, r) | |||
} | |||
func (r *Header) MarshalJSON() ([]byte, error) { | |||
s, err := jsonpbMarshaller.MarshalToString(r) | |||
return []byte(s), err | |||
} | |||
func (r *Header) UnmarshalJSON(b []byte) error { | |||
reader := bytes.NewBuffer(b) | |||
return jsonpbUnmarshaller.Unmarshal(reader, r) | |||
} | |||
func (r *Version) MarshalJSON() ([]byte, error) { | |||
s, err := jsonpbMarshaller.MarshalToString(r) | |||
return []byte(s), err | |||
} | |||
func (r *Version) UnmarshalJSON(b []byte) error { | |||
reader := bytes.NewBuffer(b) | |||
return jsonpbUnmarshaller.Unmarshal(reader, r) | |||
} | |||
func (r *Timestamp) MarshalJSON() ([]byte, error) { | |||
s, err := jsonpbMarshaller.MarshalToString(r) | |||
return []byte(s), err | |||
} | |||
func (r *Timestamp) UnmarshalJSON(b []byte) error { | |||
reader := bytes.NewBuffer(b) | |||
return jsonpbUnmarshaller.Unmarshal(reader, r) | |||
} | |||
// Some compile time assertions to ensure we don't | |||
// have accidental runtime surprises later on. | |||
// jsonEncodingRoundTripper ensures that asserted | |||
// interfaces implement both MarshalJSON and UnmarshalJSON | |||
type jsonRoundTripper interface { | |||
json.Marshaler | |||
json.Unmarshaler | |||
} | |||
var _ jsonRoundTripper = (*PartSetHeader)(nil) | |||
var _ jsonRoundTripper = (*Header)(nil) | |||
var _ jsonRoundTripper = (*Version)(nil) | |||
var _ jsonRoundTripper = (*Timestamp)(nil) |