如何将json数据插入数据库

时间:2019-11-08 10:04:36

标签: json decode

我一直试图找到将以下数据插入我的SQL数据库的代码

"{\"tables\": [{\"data\": [{\"unit_name\": \"DELTA 3934\", \"distance\": 0.61, \"_sensor3\": 0.05, \"_sensor2\": 0.03, \"_sensor1\": 0.0, \"object\": \"DELTA 3934\", \"driver\": \"\", \"unit_id\": 113740, \"track\": \"-18.348565,29.910853;-18.348475,29.910755;-18.34839,29.91073;-18.348383,29.910718;-18.348378,29.910701;-18.348375,29.910666;-18.348378,29.910648;-18.348386,29.910631;-18.348408,29.910603;-18.34846,29.910565;-18.348771,29.910275;-18.349091,29.909838;-18.349881,29.908038;-18.350548,29.906435;-18.350631,29.906276;-18.350661,29.906248;-18.350691,29.906231;-18.350728,29.906223;-18.350753,29.906223;-18.35078,29.90623;-18.350815,29.906255;-18.35089,29.906291;-18.350941,29.906301;-18.350961,29.906295;-18.350996,29.906263;-18.350996,29.906263\", \"coords\": \"-18.348565,29.910853\",

1 个答案:

答案 0 :(得分:0)

在插入数据库时​​将JSON转换为字符串,并在您希望再次使用时将其解析为字符串。