How to get the value inside without knowing the json string key?

  1. how to get the value inside without knowing the json string key?

for example, something like the following:

let result=
    {
    "err": 0,
    "message": "",
    "data": {
    "fieldCount": 0,
        "affectedRows": 1,
        "insertId": 0,
        "serverStatus": 2,
        "warningCount": 0,
        "message": "(Rows matched: 1  Changed: 0  Warnings: 0",
        "protocol41": true,
        "changedRows": 0
    }
};
console.log(result.data.changedRows);//0

however, when I only know in the js program that result is a string of json, how to get the value in a similar situation.

  1. used the corresponding function to get it, but it was not successful.
let  text=JSON.stringify(result);
console.log(text.data.changedRows);
Jul.04,2022

    function getValue(obj){
        for(var i in obj){
            typeof obj[i]==='object' ? getValue(obj[i]) : console.log(obj[i])
        }
    }
    getValue(result)//val

I think, what if the key of json is a string? For example, "name"


can get an array of the values of an object through Object.values ().
all values can be obtained by recursion.


you can specify it directly using data.key.key after using let data = JSON.parse (JSONSting).

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea677a-1dd7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea677a-1dd7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?