我正在构建一个动态表单来编辑json对象中的数据.首先,如果存在这样的事情让我知道.我宁愿不构建它,但我已经多次搜索工具,并且只找到了需要输入引号的树状结构.我很乐意将所有值视为字符串.此编辑功能适用于最终用户,因此它非常简单,不会令人生畏.
到目前为止,我有代码生成嵌套表来表示json对象.对于每个值,我显示一个表单域.我想将表单字段绑定到关联的嵌套json值.如果我可以存储对json值的引用,我将构建一个对json对象树中每个值的引用数组.我还没有找到一种方法来使用javascript.
我的最后一种方法是在编辑后遍历表格.我宁愿有动态更新,但单个提交总比没有好.
有任何想法吗?
// the json in files nests only a few levels. Here is the format of a simple case,
{
"researcherid_id":{
"id_key":"researcherid_id",
"description":"Use to retrieve bibliometric data",
"url_template" :[
{
"name": "Author Detail",
"url": "http://www.researcherid.com/rid/${key}"
}
]
}
}
$.get('file.json',make_json_form);
function make_json_form(response) {
dataset = $.secureEvalJSON(response);
// iterate through the object and generate form field for string values.
}
// Then after the form is edited I want to display the raw updated json (then I want …Run Code Online (Sandbox Code Playgroud)