presto解析json串中的布尔值

presto解析json串中的布尔值

json串为:

{
    "status":"SUCCESS",
    "bank_account_number":"8***22",
    "bank_code":"BCA",
    "updated":"2021-06-29T07:41:09.388Z",
    "is_normal_account":true,
    "name_matching_result":"MATCH",
    "id":"60dace954b96181226cfbac7"
}

目标是需要把其中的is_normal_account中的值提取出来,presto中以往拆json串用的都是json_extract,但由于这个是boolean,所以会报错。
解决方法有2个:
1.用json_extract_scalar来进行解析:

select json_extract_scalar(res_message,'$.is_normal_account') as is_normal_account

2.继续用json_extract,但把取出来的值进行转化:

(1)转成tinyint:
 select cast(json_extract(res_message,'$.is_normal_account') as tinyint)
 (2)转成boolean:
select cast(json_extract(res_message,'$.is_normal_account') as boolean)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值