Solution 1 :

You can achieve this using Array.prototype.map and Object.prototype.values.

const data = [
 {
  "rownum":2,
  "rr_id":"RR2100001",
  "ref_id":"UCL2100001",
  "cdescription":"65UGHDFH56Y</br>, 65UGHDFH56Y</br>",
  "rr_status":"Pending",
  "date_created":"2021-01-08 13:46:03"
 }
];

// Get values for all data points
const v1 = data.map(value => Object.values(value));
console.log(v1);

// Get values for first data point
const v2 = Object.values(data.shift());
console.log(v2);

Problem :

I am trying to get the value only from a json array. I have search some answer in stackoverflow but seems like not the one for me.

my code looks like this:

.done(function (data) {
     var jdata = JSON.stringify(data['queryBuilder']);
     var arrdata = JSON.parse(jdata);
     var fdata = JSON.stringify(arrdata);
     printtopdf(fdata);
);


//this code is from the answer posted here in stackoverflow:
function printtopdf(fdata) {
     var values = Object.keys(fdata).map(function (key) { return fdata[key]; });
     console.log(fdata);
}

and the result:

[
 {
  "rownum":2,
  "rr_id":"RR2100001",
  "ref_id":"UCL2100001",
  "cdescription":"65UGHDFH56Y</br>, 65UGHDFH56Y</br>",
  "rr_status":"Pending",
  "date_created":"2021-01-08 13:46:03"
 }
]

I just want to get the value only, like this:

[
 2,
 "RR2100001",
 "UCL2100001",
 "65UGHDFH56Y</br>, 65UGHDFH56Y</br>",
 "Pending",
 "2021-01-08 13:46:03"
]

Any idea? thanks.

Comments

Comment posted by jreloz

const data = fdata; const values = data.map(value => Object.values(value)); console.log(values); returns: data.map is not a function

Comment posted by fubar

You would use

By