Find length of keys from json json object
Find length of value from json json object
Find no of key value pair from json object
Find key word from json object key value pair
Find value word from json object key value pair
Find no of key value pair from json object
my json data
{
"InProgress": "2024-02-15T04:54:43.677934Z",
"Approve": "2024-02-15T04:54:50.944840Z"
}
var numberOfPairs = Object.entries(pub_status).length;
var pub_status = record.publisher_status;
var pub_statusdata = record.publisher_date ? JSON.parse(record.publisher_date) : {};
var pub_keyvalue_length = pub_statusdata ? Object.entries(pub_statusdata).length : null;
Find length of keys from json json object
var keysLength = pub_status ? Object.keys(pub_status).length : null;
var pub_status = record.publisher_status;
var pub_statusdata = record.publisher_date ? JSON.parse(record.publisher_date) : {};
var pub_status_keylength = pub_statusdata ? Object.keys(pub_statusdata)[0].length : null;
Find length of value from json json object
var numberOfValues = Object.values(pub_status).length;
var pub_status = record.publisher_status;
var pub_statusdata = record.publisher_date ? JSON.parse(record.publisher_date) : {};
var pub_status_valuelength = pub_statusdata ? Object.values(pub_statusdata)[0].length : null;
Find key word from json object key value pair
var pub_status_key = pub_statusdata ? Object.keys(pub_statusdata)[0] : null;
Find value word from json object key value pair
var pub_status_value = pub_statusdata ? Object.values(pub_statusdata)[0] : null;
Full code
{
"InProgress": "2024-02-15T04:54:43.677934Z",
"Approve": "2024-02-15T04:54:50.944840Z"
}
var pub_status = record.publisher_status;
var pub_statusdata = record.publisher_date ? JSON.parse(record.publisher_date) : {};
var pub_status_key = pub_statusdata ? Object.keys(pub_statusdata)[0] : null;
var pub_status_keylength = pub_statusdata ? Object.keys(pub_statusdata)[0].length : null;
var pub_status_value = pub_statusdata ? Object.values(pub_statusdata)[0] : null;
var pub_status_valuelength = pub_statusdata ? Object.values(pub_statusdata)[0].length : null;
var pub_keyvalue_length = pub_statusdata ? Object.entries(pub_statusdata).length : null;
// var keysLength = pub_status ? Object.keys(pub_status).length : null;
console.log("pub_statusdata");
console.log(pub_statusdata);
console.log(pub_status_key);
console.log(pub_status_keylength);
console.log(pub_status_value);
console.log(pub_status_valuelength);
console.log(pub_keyvalue_length);
output
Top comments (0)