【发布时间】:2023-03-10 08:35:01
【问题描述】:
我有一个 json 文件,我想创建模型以使用数据列表(部门编号和名称)进行自动完成,我找到了 json2ts.com 站点,但它不再工作了。 可以举个例子吗?
{
"regions": {
"alsace": [67, 68],
"aquitaine": [40, 47, 33, 24, 64],
"auvergne": [43, 3, 15, 63],
"basse-normandie": [14, 61, 50],
"bourgogne": [21, 58, 71, 89],
"bretagne": [29, 35, 22, 56],
"centre": [45, 37, 41, 28, 36, 18],
"champagne-ardenne": [10, 8, 52, 51],
"corse": ["2b", "2a"],
"franche-compte": [39, 25, 70, 90],
"haute-normandie": [27, 76],
"languedoc-roussillon": [48, 30, 34, 11, 66],
"limousin": [19, 23, 87],
"lorraine": [55, 54, 57, 88],
"midi-pyrennees": [46, 32, 31, 12, 9, 65, 81, 82],
"nord-pas-de-calais": [62, 59],
"pays-de-la-loire": [49, 44, 72, 53, 85],
"picardie": [2, 60, 80],
"poitou-charentes": [17, 16, 86, 79],
"provences-alpes-cote-dazur": [4, 5, 6, 13, 84, 83],
"rhones-alpes": [38, 42, 26, 7, 1, 74, 73, 69],
"ile-de-france": [77, 75, 78, 93, 92, 91, 95, 94]
},
"departments": {
"2a": {
"name": "Corse-du-Sud",
"formatted_name": "corse-du-sud"
},
"2b": {
"name": "Haute-Corse",
"formatted_name": "haute-corse"
},
"01": {
"name": "Ain",
"formatted_name": "ain"
},
"02": {
"name": "Aisne",
"formatted_name": "aisne"
},
"03": {
"name": "Allier",
"formatted_name": "allier"
},
...
}
你能给我一个建议吗? 至少对部门来说。 在这种情况下创建接口或类更好吗? 谢谢。
【问题讨论】:
-
Ajay 回答中提到的其中一个 VSCode 插件可在线试驾:jsontots.com
-
我注意到您是 SO 的新手 - 欢迎!如果您认为答案正确回答了您的问题,请考虑“接受”答案(通过单击复选标记)。
标签: javascript json angular typescript