I have a JSON file in my pc "WordMeanings.json" and the file has the data
{
"WordMeanings": [
{
"bangla": "ei je",
"example": "Hi there!",
"english": "Hi"
}
]
}
but I would like to append new JSON object data to existing JSON file something like the below objects by html input form
,{
"bangla": "ki obostha?",
"example": "What's up?"
"english": "How are you?"
}
The html form will be 4 inputs Bangla, Example, English and Submit button. When I will click on the Submit button the inputs will add on the existing JSON file under the existing objects in "WordMeanings.json" and it should be adding how many times i want to add.
I have created the input form and try to do it by html and javascript but i couldn't!
Assuming that WordMeanings.json
is web accessible URL:
$.getJSON('WordMeanings.json', successCallback)
successCallback
append element to JSON Object:function successCallback(data) {
data.WordMeanings.push({
"bangla": "ki obostha?",
"example": "What's up?"
"english": "How are you?"
});
}
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.