json 怎么把{"b":{"chicked": "0"}}内的chicked 解析成 int类型?

小程序 文章 2020-09-05 18:01 677 0 全屏看文

AI助手支持GPT4.0

json 怎么把{"b":{"chicked": "0"}}内的chicked 解析成 int类型?How does json parse the chicked in {"b":{"chicked": "0"}} into int type?

json 怎么把{"b":{"chicked": "0"}}内的chicked 解析成 int类型?

json 怎么把{"b":{"chicked": "0"}}内的chicked 解析成 int 类型

使用JSON.parse 会被解析成字符串

我知道可以 number() 函数 , 但是实际环境 json内嵌套比较多,用number()转的话需要很多层 for 循环



代码片段

https://developers.weixin.qq.com/s/l6yv78mX79kd

How does JSON parse the checked in {"B": {"pecked": "0"} into int type for use JSON.parse It will be parsed into a string. I know that the number() function can be used. However, there are many embedded in JSON in the actual environment. If you use number() to convert it, you need many layers of for loop code fragments https://developers.weixin.qq.com/s/l6yv78mX79kd

回答:

Distance:
<radio checked="{{a.b.chicked != '0'}}" />
陈宇明:

你直接把它当成int来用就行了

ifhtdc-:不行, radio组件会当成true 只有int 类型才是false
陈宇明:那你就用字符串“==”的方式来处理,不一定要转成int

-EOF-

AI助手支持GPT4.0