APIDefinition doesn't store the actual JSON, but it could be useful in some cases like the one you describe.
At the moment I suggest using
// If you want to use it as byte:
jsonBytes, _ := json.Marshal(s.TykMiddleware.Spec.APIDefinition.RawData)
// If you want to use it as string:
jsonStr := string(jsonBytes)
You could perform this on middleware initialization and then keep the data around, when a request comes.