Encoding map[string]interface #26
-
Hi, Can we use jingo encoder on map[string]interface data type ? Using the map_support branch Tried this code on https://play.golang.org/ panic: reflect: Key of non-map type main.AddrTable goroutine 1 [running]: Thanks
// go get github.com/bet365/jingo@map_support package main import (
) type AddrTable struct { // Create an encoder, letting it know which type of struct we're going to be encoding.
} require github.com/bet365/jingo v1.0.3-0.20210217031143-c45208b1e242 // indirect |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi Jingo works by knowing the shape of the data it is encoding ahead of time.
If you want the performance benefits possible with this package it might be worth trying to structure your data in a way that is sympathetic to this constraint. Thanks - and apologies for the length of time it took to respond. |
Beta Was this translation helpful? Give feedback.
Hi
Jingo works by knowing the shape of the data it is encoding ahead of time.
interface{}
removes its ability to know this so the only way to support it would be to use reflection, which removes the speed benefits of jingo.If you want the performance benefits possible with this package it might be worth trying to structure your data in a way that is sympathetic to this constraint.
Thanks - and apologies for the length of time it took to respond.