MarshalFast will marshal the data if fast marshal is available. This function can be used if you want to be sure the fast marshal is used or in testing. If you would like to have fallback to encoding/json you can use the Marshal() method.
(v interface{})
| 67 | // If you would like to have fallback to encoding/json you can use the |
| 68 | // Marshal() method. |
| 69 | func MarshalFast(v interface{}) ([]byte, error) { |
| 70 | _, ok := v.(marshalerFaster) |
| 71 | if !ok { |
| 72 | return nil, errors.New("ffjson marshal not available for type " + reflect.TypeOf(v).String()) |
| 73 | } |
| 74 | return Marshal(v) |
| 75 | } |
| 76 | |
| 77 | // Unmarshal will act the same way as json.Unmarshal, except |
| 78 | // it will choose the ffjson unmarshal function before falling |