|
Alex Howard |
at Aug 29, 2014 at 3:15 pm
|
⇧ |
| |
I could do that for sure, but this was research into whether or not it is
possible or not. I have concluded that it is impossible in go to do this
type of reflection whether in a type switch or with reflect package:
func SerializeEachRowSeparately(i interface{}) string {
resolved_map, ok := i.(reflect.TypeOf(i))
if !ok { return "FAILED" }
for a, b := range resolved_map { // do something to the row }
return ""
}
On Friday, 29 August 2014 16:30:06 UTC+2, Steve McCoy wrote:I might be missing something, but why not json.Encode(m) ?
On Friday, August 29, 2014 9:36:31 AM UTC-4, Alex Howard wrote:
Been using angular with Go with much success but I need to know is there
any way to range over an arbitrary map?
I have my data map[string]*CustomData and want to send it to this
function without writing custom function for each data type.
func MapToJSObject(m map[string]interface) {
for a, b := range m {
j, err := json.Encode(b)
// serialise as JS object[a] = b
}
}
the golang.org people say that if i need to use reflection i'm doing
something wrong, please help
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.