Problem mit stdClass Object

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Problem mit stdClass Object

    Hallo,

    über eine APi lese ich ein stdClass Object aus. Dass passt soweit. Nun möchte ich gern emit den Daten weiterarbeiten und da habe ich einen Holerstein.

    PHP-Code:
    stdClass Object
    (
        [
    isok] => 1
        
    [data] => stdClass Object
            
    (
                [
    online] => 1
                
    [device_status] => stdClass Object
                    
    (
                        [
    ws] => stdClass Object
                            
    (
                                [
    connected] => 
                            )

                        [
    id] => xxxxxx
                        
    [ht_ui] => Array
                            (
                            )

                        [
    devicepower:0] => stdClass Object
                            
    (
                                [
    id] => 0
                                
    [battery] => stdClass Object
                                    
    (
                                        [
    V] => 6.19
                                        
    [percent] => 100
                                    
    )

                                [
    external] => stdClass Object
                                    
    (
                                        [
    present] => 
                                    )

                            )

                        [
    mqtt] => stdClass Object
                            
    (
                                [
    connected] => 
                            )

                        [
    temperature:0] => stdClass Object
                            
    (
                                [
    id] => 0
                                
    [tC] => 19
                                
    [tF] => 66.2
                            
    )

                        [
    sys] => stdClass Object
                            
    (
                                [
    mac] => xxxx
                                
    [restart_required] => 
                                [
    time] => 12:06
                                
    [unixtime] => 1665050773
                                
    [uptime] => 3
                                
    [ram_size] => 235656
                                
    [ram_free] => 162664
                                
    [fs_size] => 458752
                                
    [fs_free] => 172032
                                
    [cfg_rev] => 12
                                
    [kvs_rev] => 0
                                
    [webhook_rev] => 0
                                
    [available_updates] => Array
                                    (
                                    )

                                [
    wakeup_reason] => stdClass Object
                                    
    (
                                        [
    boot] => deepsleep_wake
                                        
    [cause] => status_update
                                    
    )

                                [
    wakeup_period] => 43200
                            
    )

                        [
    wifi] => stdClass Object
                            
    (
                                [
    sta_ip] => xxx
                                
    [status] => got ip
                                
    [ssid] => xxx
                                
    [rssi] => -52
                            
    )

                        [
    ts] => xxxx
                        
    [cloud] => stdClass Object
                            
    (
                                [
    connected] => 1
                            
    )

                        [
    humidity:0] => stdClass Object
                            
    (
                                [
    id] => 0
                                
    [rh] => 65
                            
    )

                        [
    ble] => Array
                            (
                            )

                        [
    serial] => xxx
                        
    [_updated] => 2022-10-06 10:06:13
                        
    [code] => xxx
                        
    [_sleeping] => 1
                    
    )

            )


    Wenn ich jetzt Daten selektieren möchte dann geht das

    PHP-Code:
    $json->data->online 
    Jedoch komme ich bei den Bereich devicepower:0 nicht weiter

    PHP-Code:
    $json->data->device_status->devicepower:0->id 
    wirft einen 500er. Hat jemand einen Tipp wie ich an die Daten kommen?

    Danke schön
    Zuletzt geändert von KlausDresden; 06.10.2022, 13:50. Grund: Falsche Codeansicht

  • #2
    PHP-Code:
    $json->data->device_status->{'devicepower:0'}->id 

    Kommentar


    • #3
      Danke. Klappt

      Kommentar

      Lädt...
      X