You get the error because you are trying to turn a stdClass object into a string, something it doesn't support.

Instead of echo $decoded_traces try var_dump($decoded_traces) - that will give a diagnostic view of the object you've decoded (which I presume is what you wanted). You should find it looks like this

class stdClass#1 (2) {
  public $Coords =>
  array(5) {
    [0] =>
    class stdClass#2 (4) {
      public $Accuracy =>
      string(2) "65"
      public $Latitude =>
      string(18) "53.277720488429026"
      public $Longitude =>
      string(18) "-9.012038778269686"
      public $Timestamp =>
      string(39) "Fri Jul 05 2013 11:59:34 GMT+0100 (IST)"
    }
    [1] => (more of the same, edited for brevity)
    [2] =>
    [3] =>
    [4] =>
  }
  public $Scan =>
  string(8) "Whatever"
}

By default, json_encode will create stdClass objects like the above. If you would prefer an associative array, pass true as the second parameter to json_decode, e.g. $decoded_traces=json_decode($traces, true);

As a further aside, although stdClass can't be turned into a string, your own classes can - a class which implements the __toString magic method could be converted to a string!

Answer from Paul Dixon on Stack Overflow
Discussions

consuming graphiql error - Object of class stdClass could not be converted to string
You can't run strval() on an object that doesn't have a __toString() method, which I'm guessing that one doesn't. That would explain the error. But what is it you want to happen anyway? Converting an object to a string doesn't really make sense without defining some kind of format. More on reddit.com
🌐 r/PHPhelp
8
1
July 12, 2021
PHP convert stdClass Object to string and reduce array with max value - Stack Overflow
I want to convert a stdClass object to string and reduce an array with the max value from the stdClass object. More on stackoverflow.com
🌐 stackoverflow.com
May 12, 2014
php - foreach stdClass object converted to string - Stack Overflow
I am working response from an API which returns data in JSON in a fairly straight forward structure. Pseudo structure is best represented as: services -> service -> options -> option -> More on stackoverflow.com
🌐 stackoverflow.com
June 19, 2014
how to convert object into string in php - Stack Overflow
Actually i am dealing with web service APIs.i want to use output of one API as a input for another API. when i am trying to do this i got error like this:Catchable fatal error: Object of class std could not be converted to string in C:\ ... this is the output of first API::stdClass Object ( ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Engine Templates
enginetemplates.com › home › fix error “object of class stdclass could not be converted to string”
Fix error "Object of class stdclass could not be converted to string" - Engine Templates
April 26, 2023 - Another reason is that if you have defined a custom class and are trying to use it as a string, PHP will look for the __toString() magic method. If this method is not defined, PHP will throw this error.
🌐
Age Themes
agethemes.com › object-of-class-stdclass-could-not-be-converted-to-string
4 Solutions For Object of class stdclass could not be converted to string error - Age Themes
February 6, 2023 - The stdClass is a generic empty ... to convert the object to a string, the code will throw an error as stdClass is not designed to be converted into strings....
🌐
GalussoThemes
galussothemes.com › object-of-class-stdclass-could-not-be-converted-to-string
How to solve "Object of class stdclass could not be converted to string" error? - GalussoThemes
February 2, 2023 - The “stdClass” is a built-in PHP class that is used to represent anonymous objects (i.e., objects without a specified class). In PHP, objects are not automatically cast to strings like some other data types (e.g.
🌐
Reddit
reddit.com › r/phphelp › consuming graphiql error - object of class stdclass could not be converted to string
r/PHPhelp on Reddit: consuming graphiql error - Object of class stdClass could not be converted to string
July 12, 2021 -

Hi all I have the following code https://pastebin.com/Emsgz88u

I've managed to get the data back from graphiql, however I cannot process the object. test2 at the bottom, I end up with a error Object of class stdClass could not be converted to string

I believe that I'm not handling the returned object correctly.

var_dump of one of the objects is


stdClass Object ( [name] => 20XX-LWxxxx:Law of xxxxxxxx ) object(stdClass)#3 (1) { ["name"]=> string(27) "20XX-LWxxxx:Law of xxxxxxxx" }

I've tried the following https://stackoverflow.com/questions/28098/php-equivalent-of-net-javas-tostring

and I've been following below to process the JSON coming back from graphiql https://stackoverflow.com/questions/29308898/how-do-i-extract-data-from-json-with-php

Hope someone will help....Thanks... P

🌐
PHP
php.net › manual › en › class.stdclass.php
PHP: stdClass - Manual
Example #1 Created as a result of typecasting to object · <?php $obj = (object) array('foo' => 'bar'); var_dump($obj); The above example will output: object(stdClass)#1 (1) { ["foo"]=> string(3) "bar" } Example #2 Created as a result of json_decode() <?php $json = '{"foo":"bar"}'; var_dump(json_decode($json)); The above example will output: object(stdClass)#1 (1) { ["foo"]=> string(3) "bar" } Example #3 Declaring dynamic properties ·
🌐
Datainflow
datainflow.com › question › how-to-convert-stdclass-object-to-string-in-php
How to convert stdclass object to string in PHP - Datainflow
November 22, 2021 - $ArrayData = Array ( [0] => stdClass Object ( [item_length] => 6 [item_width] => 4 [item_height] => 2 [item_weight] => 20 ) ) echo $ArrayData[0]->item_length; ... Hi Do you want to make web application with php and php framework(CI, Laravel)? Want to make android application with hybrid framework ?
Find elsewhere
🌐
LTHEME
ltheme.com › object-of-class-stdclass-could-not-be-converted-to-string
Object of class stdclass could not be converted to string - LTHEME
September 21, 2022 - As we mentioned above, the Object of class stdclass could not be converted to string is an error of PHP function. Stdclass should return an array, not a single object.
🌐
codestudy
codestudy.net › blog › object-of-class-stdclass-could-not-be-converted-to-string
How to Fix 'Object of class stdClass could not be converted to string' Error in PHP (CodeIgniter Example) — codestudy.net
The error “Object of class stdClass could not be converted to string” occurs when PHP tries to convert an stdClass object into a string implicitly. PHP can only convert scalar values (strings, integers, floats) to strings by default.
🌐
CodeIgniter
forum.codeigniter.com › thread-73109.html
20.03.19 Message: Object of class stdClass could not be converted to string
CodeIgniter Forums Using CodeIgniter General Help 20.03.19 Message: Object of class stdClass could not be converted to string ... CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications.
🌐
Techie Delight
techiedelight.com › home › java › convert an object to a string in php
Convert an object to a string in PHP | Techie Delight
July 7, 2026 - Note that the object can now be cast to a string, used with the strval() function, or in the echo statement. ... You can also use the print_r() function to get the indented string representation of PHP objects, including their protected and ...