我想用jq转换这个JSON
[
{
"one": 37
},
{
"two": "2017-09-15T19:31:55"
}
]
到这个
CREATE TABLE `Study` ( `Id` INT NOT NULL AUTO_INCREMENT , `Start` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY (`Id`)) ENGINE = InnoDB;
CREATE TABLE `Study_Monitoring` ( `Id` INT NOT NULL AUTO_INCREMENT , `Study_Id_FK` INT NOT NULL, `StartPhase` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY (`Id`)) ENGINE = InnoDB;
INSERT INTO `Study` (`Start`)
VALUES (DATE("2016-05-25")),(DATE("2016-05-25")),(DATE("2016-05-25")),(DATE("2016-05-25")),(DATE("2016-05-25"));
INSERT INTO `Study_Monitoring` (`Study_Id_FK`, `StartPhase`)
VALUES (0, NOW()), (1, NOW()),(2, NOW()),(3, NOW()),(4, NOW())
怎么做?
谢谢
答案 0 :(得分:1)
当谈到涉及JSON对象键的操作时,to_entries
(和它的朋友,with_entries
)是你的朋友:
map(to_entries[] | {(.key): .value})
还请注意.key
周围的括号。