JSON converts the contained object to a JSON string representation
()
| 48 | // JSON converts the contained object to a JSON string |
| 49 | // representation |
| 50 | func (m Map) JSON() (string, error) { |
| 51 | for k, v := range m { |
| 52 | m[k] = cleanUp(v) |
| 53 | } |
| 54 | |
| 55 | result, err := json.Marshal(m) |
| 56 | if err != nil { |
| 57 | err = errors.New("objx: JSON encode failed with: " + err.Error()) |
| 58 | } |
| 59 | return string(result), err |
| 60 | } |
| 61 | |
| 62 | func cleanUpInterfaceArray(in []interface{}) []interface{} { |
| 63 | result := make([]interface{}, len(in)) |