Filter post content in REST API

It looks to me like you’ve written $data->$data[...] where you mean to have $data->data[...]. The “object to string” conversion error is probably due to the second $data, where PHP expects an object’s property name but is getting another reference to the $data object.