How to convert dynamic JSON string to javascript array

san88

I have a php web page returning json string. json string is like this .

   {
   "employees": [
   {
  "fname": "sdsdsd",
  "lname": "sdsd",
  "phone": "sdsd",
  "gender": "female",
  "dob": "1990-03-11",
  "address": "03",
  "nic": "erer",
  "email": "erererer",
  "empid": "ererere",
  "designation": "sdsds",
  "qualifications": "dsds"
 }
 ]

   }

this is a dynamic page (values can change). i want to display these strings in a jquery mobile listview. please tell me how should my javascript function looks like..

Zaheer Ahmed

Append extra an [ and ] to the beginning and end of the string. This will make it an array.

jQuery:

var json = '{"id":1,"name":"Test1"},{"id":2,"name":"Test2"}';
var jsonArray = $.parseJSON('[' + json + ']');

JavaScript:

var jsonArray = eval('(' + json + ')');

Here is Jsfiddle Demo

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

javascript - convert string to json array

How to convert mongodb response array from javascript object to JSON string

Javascript how to convert Json array values into string using join

How to convert array to json string in javascript having indexes inside the element

How to convert json into String array

Convert JSON string to array of JSON objects in Javascript

In javascript how to convert string to array and array to string

How to convert String into Array in javaScript

How to convert this string to a javascript array?

How to convert JSON to Array in Javascript

How to convert array of string into json string in hive?

Javascript convert a JSON string to an array of arrays

Convert JSON string to an array in multistep Form in JavaScript?

Javascript Take JSON string convert to array

Javascript convert Json to an array string format

Convert json string with duplicate keys into javascript array

How to convert JSON Array to JSON String jquery

How to convert array or string to array in JavaScript?

How to convert a jquery array to a string array in javascript

How to convert array undefined to array string in javascript

how to convert json array to javascript array

How to convert an array of JSON into an array of javascript object?

How to convert JSON array to OBJECT array javascript?

How to convert JSON Response to String Array

How to convert JSON string to a PHP array?

How to convert a string to a JSON array using NiFi

How to convert a PHP array into json string

How to convert string to nested json array

How to convert array string to JSON value?