如何将JSON映射到SQL Schema? [英] How to map JSON to SQL Schema?
本文介绍了如何将JSON映射到SQL Schema?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个示例JSON对象,我需要一个架构: p>
{
action:index.html,
method:post,
元素:
[
{
type:fieldset,
caption:用户信息,
elements
[
{
name:email,
caption:电子邮件地址,
type:text,
占位符:Eg user@example.com,
validate:
{
email:true
}
},
{
name:password,
caption:密码,
type:密码,
id:注册密码,
validate:
{
required:true,
minlength:5,
messages:
{
required:请输入密码,
minlength:至少{0}个字符长
}
}
},
{
name:password-repeat,
caption:重复密码,
type:password,
validate:
{
等于:#注册密码,
消息:
{
等于:请重复您的密码
}
}
},
{
type:radiobuttons,
caption:Sex,
name:sex ,
class:labellist,
options:
{
f:女,
m
}
}
]
]
}
我可能会使用一个键/值对来执行这些代码,但是我以为我需要一个很好的数据库策略。任何帮助或想法将不胜感激。
解决方案
您应该为数据结束创建实体,然后反序列化您的json这些实体。
I have a complex JSON object that I want to persist and manage/modify in a database. Is there any JSON relation managers to convert to a SQL schema, or some strategy to do this manually?
This is a sample JSON object I need a schema for:
{
"action": "index.html",
"method": "post",
"elements":
[
{
"type": "fieldset",
"caption": "User information",
"elements":
[
{
"name": "email",
"caption": "Email address",
"type": "text",
"placeholder": "E.g. user@example.com",
"validate":
{
"email": true
}
},
{
"name": "password",
"caption": "Password",
"type": "password",
"id": "registration-password",
"validate":
{
"required": true,
"minlength": 5,
"messages":
{
"required": "Please enter a password",
"minlength": "At least {0} characters long"
}
}
},
{
"name": "password-repeat",
"caption": "Repeat password",
"type": "password",
"validate":
{
"equalTo": "#registration-password",
"messages":
{
"equalTo": "Please repeat your password"
}
}
},
{
"type": "radiobuttons",
"caption": "Sex",
"name": "sex",
"class": "labellist",
"options":
{
"f": "Female",
"m": "Male"
}
}
]
]
}
I will probably use a key/value pair to carry them through the code, but I am thinking I need an excellent database strategy first. Any help or ideas would be greatly appreciated.
解决方案
Have a look at Parse JSON in C#
You should create entities for your data end then deserialize your json to these entities.
这篇关于如何将JSON映射到SQL Schema?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文