我有一個數據表。我將它導出爲JSON。它看起來像這樣:Postgresql - JSON
{"@timestamp":"2015-05-18T08:57:48.646Z","ip":"0.0.0.0","extension":"php","response":"404","geo":{"coordinates":{"lat":33.48288111,"lon":-90.98561389},"src":"MD","dest":"ID","srcdest":"MD:ID"},"@tags":["success","info"]}
有成千上萬這些線。不過,我想在JSON的每一行之前插入一個如下所示的增量ID:{「index」:{「_ id」:「1」}}。輸出應該是這個樣子:
{"index":{"_id":"1"}}
{"@timestamp":"2015-05-18T08:57:48.646Z","ip":"0.0.0.0","extension":"php","response":"404","geo":{"coordinates":{"lat":33.48288111,"lon":-90.98561389},"src":"MD","dest":"ID","srcdest":"MD:ID"},"@tags":["success","info"]}
{"index":{"_id":"2"}}
{"@timestamp":"2015-05-18T08:57:48.646Z","ip":"0.0.0.0","extension":"php","response":"404","geo":{"coordinates":{"lat":33.48288111,"lon":-90.98561389},"src":"MD","dest":"ID","srcdest":"MD:ID"},"@tags":["success","info"]}
任何想法我怎麼能做到這一點的JSON或如果我能在Postgres的那種方式出口嗎?
是否要更改導出(文本)文件,或者是否要更改用於導出的SQL語句中的數據? –
以任何方式。我只需要一個帶有所述格式的json輸出。基本上,我有它在postgresql和導出到JSON。這就是我得到的。我只需要在我的原始帖子中看到的每個訂單項都添加索引。任何想法將不勝感激。 @a_horse_with_no_name –
你目前如何將數據導出到JSON?如果你想得到正確的答案,你應該添加表格定義和你當前的查詢。 – Patrick