I'm working with mongoDB, and I used a wrapper mongo/Postegres. Now, I can find my tables and data.
我正在使用mongoDB,我使用了一个包装器mongo / Postegres。现在,我可以找到我的表和数据。
I want to do some statistics but I can't reach objects that got json type in Postgres.
我想做一些统计,但我无法到达Postgres中获得json类型的对象。
My problem is that I got all the object in json but I need to separate the fields.
我的问题是我在json中获得了所有对象,但我需要将字段分开。
I used this :
我用过这个:
CREATE FOREIGN TABLE rents( _id NAME, status text, "from" json )
SERVER mongo_server
OPTIONS (database 'tr', collection 'rents');
The field "from" is an object.
字段“from”是一个对象。
I found something like this :
我发现了这样的事情:
enter code here
but nothing happened
但什么都没发生
1 个解决方案
#1
0
The error (why a screenshot??) means that the data are not in valid json
format.
错误(屏幕截图的原因??)意味着数据不是有效的json格式。
As a first step, you could define the column as type text
instead of json
. Then querying the foreign table will probably work, and you can see what is actually returned and why PostgreSQL thinks that this is not valid JSON.
作为第一步,您可以将列定义为类型文本而不是json。然后查询外表可能会起作用,你可以看到实际返回的内容以及为什么PostgreSQL认为这不是有效的JSON。
Maybe you can create a view on top of the foreign table that converts the value to valid JSON for further processing.
也许你可以在外表上创建一个视图,将视图转换为有效的JSON以便进一步处理。
#1
0
The error (why a screenshot??) means that the data are not in valid json
format.
错误(屏幕截图的原因??)意味着数据不是有效的json格式。
As a first step, you could define the column as type text
instead of json
. Then querying the foreign table will probably work, and you can see what is actually returned and why PostgreSQL thinks that this is not valid JSON.
作为第一步,您可以将列定义为类型文本而不是json。然后查询外表可能会起作用,你可以看到实际返回的内容以及为什么PostgreSQL认为这不是有效的JSON。
Maybe you can create a view on top of the foreign table that converts the value to valid JSON for further processing.
也许你可以在外表上创建一个视图,将视图转换为有效的JSON以便进一步处理。