From a2636b27fdadb2b7951fa35fe301e8e6b41fc28a Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 22 Feb 2023 20:52:20 +0000 Subject: Modify subex to take JSON split into "data" Currently no way to reassemble the data on the other side Much of the potential data cannot be interacted with meaningfully, only the string functionality is implemented Should rename data to something else --- walk/walk.go | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'walk/walk.go') diff --git a/walk/walk.go b/walk/walk.go index 19180b4..1df7a6e 100644 --- a/walk/walk.go +++ b/walk/walk.go @@ -16,12 +16,39 @@ const ( MapBegin MapEnd ) +func (value TerminalValue) Pieces(out chan<- Datum) { + out<-value +} + type ValueNull struct {} +func (value ValueNull) Pieces(out chan<- Datum) { + out<-value +} type ValueBool bool +func (value ValueBool) Pieces(out chan<- Datum) { + out<-value +} type ValueNumber float64 +func (value ValueNumber) Pieces(out chan<- Datum) { + out<-value +} + +type StartString struct {} +type EndString struct {} type ValueString string +func (value ValueString) Pieces(out chan<- Datum) { + out<-StartString{} + for _, char := range value { + out<-char + } + out<-EndString{} +} -type WalkValue interface {} +type Datum interface {} + +type WalkValue interface { + Pieces(out chan<- Datum) +} type WalkItem struct { Value WalkValue @@ -297,7 +324,7 @@ func jsonOutValue(in *WalkItemStream, indent int, doIndent bool) WalkValue { jsonOutMap(in, indent) return nil default: - return token + return token.Value } default: panic("Invalid WalkValue") -- cgit v1.2.3