Home » Javascript » How to change data format in java script [on hold]

How to change data format in java script [on hold]

Posted by: admin August 19, 2018 Leave a comment

Questions:

I am new in JavaScript and PHP. I read a data into variable ‘data’ using the following codes.

<script>
var data= '<?php echo 
       file_get_contents("http://localhost/reporting/badge.php"); ?>';
</script>

The URL returns data is in the below format.the ‘data’ is :

[{"SubDomain":"AI","Count":"52"},
 {"SubDomain":"DA","Count":"34"},
 {"SubDomain":"DP","Count":"17"},
 {"SubDomain":"IS","Count":"5"},]

I want to change the ‘data’ like this:-

[{SubDomain: "AI", Count: 52},
 {SubDomain: "DP", Count: 34},
 {SubDomain: "DP", Count: 17},
 {SubDomain: "IS", Count: 5},];

How to do it using javascript?

Answers: