Postgresql 9.1 在Postgresql中获取JSON对象值

Postgresql 9.1 在Postgresql中获取JSON对象值,postgresql-9.1,Postgresql 9.1,我的表中有一个Json属性,如下所示: Select Coalesce(attributes,'') attributes From mytable {"batteryLevel":89.0,"distance":7.47,"totalDistance":5659.61,"motion":false} {"batteryLevel":35.0,"distance":2491.

我的表中有一个Json属性,如下所示:

Select Coalesce(attributes,'') attributes From mytable

{"batteryLevel":89.0,"distance":7.47,"totalDistance":5659.61,"motion":false}
{"batteryLevel":35.0,"distance":2491.39,"totalDistance":8412.53,"motion":true}
如何从查询中获取距离对象值,我希望如下所示:

选择合并(属性“”)属性、attributes.batteryLevel、attributes.distance From mytable

有人能帮我吗?

Postgres 9.1是,它不支持任何JSON函数或数据类型,因此提取属性值将非常复杂(而且难看)。无论如何,您应该从9.1升级,在继续使用丑陋的解决方案之前应该考虑这一点。