[英]How to convert number in json to string in typescript interface
{
"id": 13,
"name": "horst",
}
to到
interface A {
id: string;
name: string;
}
when A
json converts to A
object, I expected to convert id
from number to string automatically.当
A
json 转换为A
对象时,我希望自动将id
从数字转换为字符串。 but it doesn't convert.但它不会转换。
i want to convert from number to string by type infer.我想通过类型推断从数字转换为字符串。 when a json parse to object.
当 json 解析为对象时。 how can i do it?
我该怎么做?
ps.附: sorry my English is poor..
对不起我的英语很差..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.