我有一个文件,其中包含JSON格式的实体列表:
[
{
"id": "IST-AFRICA-2018_Sensor6",
"type": "Device",
"TC": {
"type": "Sensor",
"value": 24.26,
"metadata": {
...
我可以在Orion中一次性添加所有内容吗?
我尝试过:
curl -v localhost:1026/v2/op/update -s -S --header 'Content-Type: application/json' --header 'Fiware-Service:waziup' -d '{ "actionType": "APPEND", "entities": `cat file.json`}"
但没有成功。
答案 0 :(得分:1)
我找到了这个解决方案:
jq -c -r '.[]' entities.json | while read i; do
echo "inserting $i"
echo $i | curl -X POST "http://localhost:1026/v2/entities" -s -S --header 'Content-Type:application/json' -d @-
done