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
🌐
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

Handling an error in GraphQL Feb 18, 2021
r/graphql
5y ago
GraphQL Error Handling Mar 7, 2023
r/graphql
3y ago
Help with Error Apr 12, 2022
r/PHPhelp
4y ago
More results from reddit.com
Discussions

php - Catchable fatal error: Object of class stdClass could not be converted to string - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
php - json_encode error Object of class stdClass could not be converted to string - Stack Overflow
I have a json_encode element and i have to implode it like that with the debug print_f the array result like that Arr... More on stackoverflow.com
🌐 stackoverflow.com
php - I have issue with decoding json ex. '{"a":"b"}' - WordPress Development Stack Exchange
Hey I am trying to send JSON data from (WRITE AN EXCERPT (OPTIONAL)) this section. Let say I pass this '{"a":"b"}' as Map now in the wordpress templete I tried to get this so I ... More on wordpress.stackexchange.com
🌐 wordpress.stackexchange.com
June 27, 2023
php - problems with JSON Decode & strings - Stack Overflow
Catchable fatal error: Object of class stdClass could not be converted to string More on stackoverflow.com
🌐 stackoverflow.com
🌐
Laracasts
laracasts.com › discuss › channels › eloquent › json-casts-as-object-issue-with-conversion-to-string
JSON $casts as Object - Issue with conversion to string
ErrorException in helpers.php line 747: Object of class stdClass could not be converted to string in helpers.php line 747 at HandleExceptions->handleError('4096', 'Object of class stdClass could not be converted to string','/home/vagrant/Code/crmanager/vendor/laravel/framework/src/Illuminate/Support/helpers.php', '747', array('search' => '?', 'replace' => array('08715291', object(stdClass)), 'subject' => 'select * from "chdata" where ("company_number" = 08715291 and "json_data" = ?) limit 1', 'value' => object(stdClass))) at preg_replace('/?/', object(stdClass), 'select * from "chdata" where ("company_number" = 08715291 and "json_data" = ?) limit 1', '1') in helpers.php line 747
🌐
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.
🌐
Stack Exchange
wordpress.stackexchange.com › questions › 417089 › i-have-issue-with-decoding-json-ex-ab
php - I have issue with decoding json ex. '{"a":"b"}' - WordPress Development Stack Exchange
June 27, 2023 - If $extra is a valid JSON string, When you json_decode() it, you'll get an object (specifically, a stdClass object). There's no way to echo a stdClass object; when I try that, I get a PHP warning: PHP Warning: Uncaught Error: Object of class stdClass could not be converted to string
🌐
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 - To resolve this error, you can use object properties as strings, convert the object to an array, or use the __toString() method. By following these steps, you can easily resolve the “Object of class stdClass could not be converted to string” ...
Find elsewhere
🌐
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....
🌐
PHP
bugs.php.net › bug.php
PHP :: Bug #42270 :: stdClass could not be converted to string
go to bug id or search bugs for · Before you report a bug, please make sure you have completed the following steps:
🌐
WHMCS.Community
whmcs.community › developing & extending whmcs › developer corner
Object of class stdClass could not be converted to string in .... ccfunctons.php line 0
January 21, 2019 - I created a payment module for WHMCS,,,, I have a user with trouble in WHMCS 7.1... the error is on imagem, there is any ideia what is it could be??? thanks