我要找的是我必须补充的 复选框到json的父对象,而不是对于子json。然后我必须保存父json对象的值。
[
{
"tweetText": "P/s Q' 2013 K IPL Min Kis Batsamin Ni Sub Si Ziada Runs Bnay\n....03448972100",
"urlsMentioned": [
],
"usersMentioned": [
],
"source": "<a href=\"http://twitter.com/devices\" rel=\"nofollow\">txt</a>",
"tweetId": 364239659250892800,
"reTweetCount": 0,
"reTweeted": false,
"createdDate": "Mon Aug 05 09:51:16 IST 2013",
"user": {
"location": "Swat, Pakistan",
"userId": 1558242139,
"screenName": "ZaLiM_Shairi",
"userName": "Best Forever S.FAHAD",
"profileDescription": "Only for Sad and Romantic Poetry\r\nFollow\r\n@Zalim_Shairi &@Ghamgeen_Shairi\r\nS. Fahad & I. KHAN owners of Best Forever Group",
"language": "en"
},
"hashTags": [
]
},
{
"tweetText": "RT @ItsPsychoLOVE: Jangan mencintai seseorang yg tdk kamu percaya, tapi percayailah seseorang yg mencintaimu dan berusaha untuk menerimanya…",
"urlsMentioned": [
],
"usersMentioned": [
{
"userId": 856172684,
"screenName": "ItsPsychoLOVE",
"userName": "Open FollowBack :))"
}
],
"source": "<a href=\"http://blackberry.com/twitter\" rel=\"nofollow\">Twitter for BlackBerry�</a>",
"tweetId": 364239488811155460,
"reTweetCount": 534,
"reTweeted": true,
"createdDate": "Mon Aug 05 09:50:36 IST 2013",
"user": {
"location": "",
"userId": 1147194883,
"screenName": "trianssa",
"userName": "Anssa••",
"profileDescription": "Ku tau kau tak tersenyum melihatku menangis. Maka sekuat tenaga ku relakan saat kepergianmu :,)",
"language": "id"
},
"reTweetedStatus": {
"tweetText": "Jangan mencintai seseorang yg tdk kamu percaya, tapi percayailah seseorang yg mencintaimu dan berusaha untuk menerimanya sepenuh hati. #IPL",
"urlsMentioned": [
],
"usersMentioned": [
],
"source": "<a href=\"http://www.tweetdeck.com\" rel=\"nofollow\">TweetDeck</a>",
"tweetId": 361389482198573060,
"reTweetCount": 534,
"reTweeted": false,
"createdDate": "Sun Jul 28 13:05:41 IST 2013",
"user": {
"location": "In your hearts~",
"userId": 856172684,
"screenName": "ItsPsychoLOVE",
"userName": "Open FollowBack :))",
"profileDescription": "Bukan dengan kata2, tp dengan upaya yg dapat membuktikan sebuah kepercayaan. FOLLOW-� @ItsPsychoLOVE �- Dokter konsultasi percintaan (???)",
"language": "id"
},
"hashTags": [
"IPL"
]
},
"hashTags": [
]
}
]`
在上面的示例中,我有2个具有子对象的父对象。我想在当前使用jquery.jsoneditor.js的父对象中添加复选框 http://www.daviddurman.com/jquery-json-editor-plugin.html
当我在js中编辑代码时 `
function construct(opt, json, root, path) {
path = path || '';
root.children('.item').remove();
for (var key in json) {
if (!json.hasOwnProperty(key)) continue;
var item = $('<div>', { 'class': 'item', 'data-path': path }),
property = $(opt.propertyElement || '<input>', { 'class': 'property' }),
value = $(opt.valueElement || '<input>', { 'class': 'value' });
if (isObject(json[key]) || isArray(json[key])) {
addExpander(item);
}
if (isObject(json[key])) {
item.append('<input type="checkbox">');
}
item.append(property).append(value);
root.append(item);
property.val(key).attr('title', key);
var val = stringify(json[key]);
value.val(val).attr('title', val);
assignType(item, json[key]);
property.change(propertyChanged(opt));
value.change(valueChanged(opt));
if (isObject(json[key]) || isArray(json[key])) {
construct(opt, json[key], item, (path ? path + '.' : '') + key);
}
}
}
它还为子对象添加了复选框。是否有可能找到这是否是父对象?是这样的任何方式只向父母添加复选框?提前致谢