Find below my json output
[
{
"tname": "yyyy",
"first_name": "xxx",
"last_name": "yyyy",
"pri": "pub",
"skills": "[{\"description\": \"1 YEAR\", \"Name\": \"Programming\", \"Competence\": \"PHP\"}, {\"description\": \"2 YEAR\", \"Name\": \"Programming\", \"Competence\": \"JAVA\"}]",
"contact_phone": "875433333333",
"experience_years": 2,
"experience": "[{\"description\": \"deve\", \"endYear\": \"2014-07-08\", \"designation\": \"developer\", \"startYear\": \"2013-03-12\", \"companyName\": \"xxx\"}, {\"description\": \"dev\", \"endYear\": \"2015-02-03\", \"designation\": \"developer\", \"startYear\": \"2014-02-09\", \"companyName\": \"yyy\"}]",
"accomplishments": "[{\"Institution\": \"EVR COLLG\", \"description\": \"EVT\", \"Name\": \"xxx\", \"Year\": \"2013-04-02\"}, {\"Institution\": \"ASV COLLG\", \"description\": \"ASV\", \"Name\": \"YYY\", \"Year\": \"2014-02-02\"}]",
"contact_email": "xx@gmail.com",
"education_gist": [
"SSLC",
"HSC",
"UG",
"PG"
],
"address": " \r\n \r\n \t\t\t\t\t\t\t\t\tno:7, XXX XX, YYYY- 560543\t\r\n \t\t\t\t\t\t\t\t \r\n ",
"about_me": " \r\n I am xx from XXX, i am a WWW DDD.\r\n \r\n \r\n\r\n ",
"education": "[{\"description\": \"school first\", \"startYear\": \"2004-02-02\", \"grade\": \"95\", \"collegeName\": \"govt high school\", \"endYear\": \"2004-01-04\", \"qualification\": \"SSLC\"}, {\"description\": \"class first\", \"startYear\": \"2006-01-01\", \"grade\": \"90\", \"collegeName\": \"gov boy hr school\", \"endYear\": \"2006-12-04\", \"qualification\": \"HSC\"}, {\"description\": \"department first\", \"startYear\": \"2012-06-09\", \"grade\": \"94\", \"collegeName\": \"B.Sc\", \"endYear\": \"2015-07-02\", \"qualification\": \"UG\"}, {\"description\": \"GOLD MEDAL\", \"startYear\": \"2015-07-09\", \"grade\": \"9.8\", \"collegeName\": \"MCA\", \"endYear\": \"2015-07-25\", \"qualification\": \"PG\"}]",
"user_name": "xx",
"projects": "[{\"Company\": \"XXX\", \"endYear\": \"2015-08-14\", \"Name\": \"XYZ PROJECT\", \"startYear\": \"2015-07-29\", \"description\": \"DEVELOPER\"}, {\"Company\": \"YYYY\", \"endYear\": \"2015-07-31\", \"Name\": \"ABC PROJECT\", \"startYear\": \"2015-07-01\", \"description\": \"DESIGNER\"}]"
}
]
And i want to remove the (") double quotes before "[ and after ]" the square brackets
"skills": "[{\"description\": \"1 YEAR\", \"Name\": \"Programming\", \"Competence\": \"PHP\"}, {\"description\": \"2 YEAR\", \"Name\": \"Programming\", \"Competence\": \"JAVA\"}]",
"skills":
"[
and \\"JAVA\\"}
]"
,
I wanted the solution using jquery or javascript, don't want in PHP, Give me the solution if any one knows. Thanks in advance
Say your data is called data
data[0].skills = JSON.parse(data[0].skills);
// etc...
If you want to keep the data internal to the array as strings then:
data[0].skills = JSON.parse(data[0].skills).map(function(obj) {
return JSON.stringify(obj);
});
And to do it all programmatically
data.forEach(function(obj){
for (var key in obj) {
if (typeof obj.key === "string" && obj.key[1] === "[") {
obj[key] = JSON.parse(obj[key]).map(function(inArray) {
return JSON.stringify(inArray);
});
}
}
});
This is what you should do, simple regex substitute
jsonData = '"["smt": "smtelse" ]"'; jsonData = jsonData.replace(/"\\[/g, '['); jsonData = jsonData.replace(/\\]"/g, ']');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.