json - Parse complex JSON in Typescript
问题描述
The response of a request delivers a JSON. The structure of the JSON looks like this:
{
"32": {
"docKey": "32",
"outletId": 32,
"mdngOutlet": {
"outletBasic": {
"outletId": 32,
}
}
},
"33": {
"docKey": "32",
"outletId": 32,
"mdngOutlet": {
"outletBasic": {
"outletId": 32,
}
}
},
"34": {
"docKey": "32",
"outletId": 32,
"mdngOutlet": {
"outletBasic": {
"outletId": 32,
}
}
},
"35": {
"docKey": "32",
"outletId": 32,
"mdngOutlet": {
"outletBasic": {
"outletId": 32,
}
}
},
}
What does the interface look like? 32, 33, 34, ... seem to act like map. How can you use a map in an interface?
解决方案
Typescript 界面可以有动态键。
interface YourJSON{
[key: string]: yourObjectInterface
}
推荐阅读
- javascript - 无法禁用 X-Powered-By: Express
- java - 为什么 != 在 if 语句的开头与结尾不同?
- python - 如何在没有程序阻塞的情况下使用图形工具显示图形?
- javascript - 从另一个文件调用 javascript 函数
- python - 如何使用 Tkinter 中的按钮来停止运行不同的代码行?
- javascript - Node js:在module.exports中调用内部函数
- c# - 使用 epplus 导出时动态合并行
- hadoop - Hive 3.1.1安装问题:找不到hadoop安装:$HADOOP_HOME or $HADOOP_PREFIX must be set or hadoop must be in the path
- r - R传播错误:行的重复标识符
- c - 如何计算 str 类型数组的大小?