ErrorException: Object of class Illuminate\Testing\AssertableJsonString could not be converted to string
Issue
Laravel decodes JSON responses into an AssertableJsonString
for ease of testing APIs. However, you may be using this object in a capacity where PHP is attempting to convert it to a string
.
Solution
The most likely cause of this error relates to a change in Laravel 8, where the decodeResponseJson
no longer accepts an argument. Due to the dynamic nature of PHP, you may still call this method with an argument but it will return the entire JSON object, instead of the value for the passed key.
If you are calling decodeResponseJson
with an argument, you should update your code to use json
instead. If you are not using decodeResponseJson
and receiving this error, you are likely passing the entire AssertableJsonString
object where a string
is expected.