Orion Context Broker - 在实体中推送数组元素

时间:2015-02-05 15:32:31

标签: arrays push entities fiware-orion

我做了实体

  

{      " contextElements":[          {              "输入":" T1",              " isPattern":" false",              " id":" E1",              "属性":[              {                  "姓名":" A",                  "输入":" T",                  "价值":[" 22" ,                             {                                " x":[" x1"," x2"],                                " y":" 3"                             },                             [" z1"," z2" ]                           ]              },              {                  "姓名":" B",                  "输入":" T",                  "价值":{                     " x":{                             " x1":" a",                             " x2":" b"                     },                     " y":[" y1"," y2" ]                  }              }              ]          }      ]      " updateAction":" APPEND"    }

现在我想在数组中添加值,字符串(" NEW VALUE")和json对象({" NEW":" OBJECT"} )

  

{      " contextElements":[          {              "输入":" T1",              " isPattern":" false",              " id":" E1",              "属性":[              {                  "姓名":" A",                  "输入":" T",                  "价值":[" 22" ,                             {                                " x":[" x1"," x2"],                                " y":" 3"                             },                             [" z1"," z2" ],               "新价值",               {" NEW":" OBJECT"}                           ]              }              ]          }      ]      " updateAction":"更新"    }

可以像在array.push()中那样添加新值吗?

保存以前的值,并在之后添加新值。

1 个答案:

答案 0 :(得分:1)

目前(Orion 0.18.1),添加元素添加到属性值为向量的唯一方法是使用包含新元素的新向量更新此属性。

但是,我认为推送属性值中的元素是需要更新整个矢量的矢量whitout是一个值得考虑的有趣特性,因此我们创建了an issue about it并最终实现了它。 / p>