I have a json object like this actually it is coming dynamically.
For example we can use this Json object.
var JsonObj= { "one":1, "two":2, "three":3, "four":4, "five":5 };
But i want to change it some thing like this using javascript or jquery.
var sample = [
{
"label":"one",
"value":1
},
{
"label":"two",
"value":2
},
{
"label":"three",
"value":3
},
{
"label":"four",
"value":4
},
{
"label":"five",
"value":5
}
];
var JsonObj= { "one":1, "two":2, "three":3, "four":4, "five":5 };
var arr = [];
for(property in JsonObj) {
arr.push(
{"label":property,
"value":JsonObj[property]})
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With