I have updated my jSon object using the code
<script type="text/javascript" >
jQuery(document).ready(function($){
var lessonId = "3423671";
$.getJSON('data.json', function(json) {
$.each(json, function(i, data) {
$.each(this.courseStarted[0].courseDetails[0].lessonDetails, function(){
if(this.lessonId == lessonId){
this.quiz = "This row updated";
}
});
});
});
});
</script>
Here i am updating my json
object inside the if condition. Is there any method to get me the new updated json
object to print into a html div tag as text in the json format
.
Since json
has your object data (retrieved from your server), and your code just updated it, you can transform it into a string again using JSON.stringify(json)
. AFAIK the JSON
object is natively supported in most browsers.
JSON.stringify({ foo: "lorem", bar: "ipsum" }, null, '\t');
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.