From 1efd55acd631664ab37e5124e63f2c1b608c7a48 Mon Sep 17 00:00:00 2001 From: gfanton <8671905+gfanton@users.noreply.github.com> Date: Mon, 21 Mar 2022 15:07:53 +0100 Subject: [PATCH] feat: add json marshaler interface to log's entry interface Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com> --- entry/entry.go | 8 ++++++++ iface/iface.go | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/entry/entry.go b/entry/entry.go index c8c866f..1c31467 100644 --- a/entry/entry.go +++ b/entry/entry.go @@ -511,6 +511,14 @@ func (e *Entry) IsParent(b iface.IPFSLogEntry) bool { return false } +func (e *Entry) MarshalJSON() ([]byte, error) { + return json.Marshal(e) +} + +func (e *Entry) UnmarshalJSON(payload []byte) error { + return json.Unmarshal(payload, e) +} + // FindChildren finds an entry's children from an Array of entries. // // Returns entry's children as an Array up to the last know child. diff --git a/iface/iface.go b/iface/iface.go index 8cf2ab4..e918c23 100644 --- a/iface/iface.go +++ b/iface/iface.go @@ -2,6 +2,7 @@ package iface import ( "context" + "encoding/json" "time" "github.com/ipfs/go-cid" @@ -173,6 +174,10 @@ type IPFSLogEntry interface { Equals(b IPFSLogEntry) bool IsParent(b IPFSLogEntry) bool Defined() bool + + // marshaler + json.Marshaler + json.Unmarshaler } type IPFSLogLamportClock interface {