首页 > 解决方案 > Using Cygnus to write in mongo db with no string

问题描述

I'm trying to use Orion CB and Cygnus to write information about water quality and water consume and I need to write in float type. However it is impossible to me to know if there is any possibility to write this with float or double format. Could someone tell me if this possibility exists?

标签: fiwarefiware-orionfiware-cygnus

解决方案


FIWARE Orion 文档中所述,您可以使用 JSON 格式自由指定实体属性。

因此,您将拥有以下格式的实体:

{
  "id": "entityID",
  "type": "entityType",
  "attr_1": <val_1>,
  "attr_2": <val_2>,
  ...
  "attr_N": <val_N>
}

其中每个<val_n>将采用以下格式:

{
  "type": <...>,
  "value": <...>,      
  "metadata": <...>
}

因此,您可以将某些实体描述为,例如:

{
  "id": "sensor_ID",
  "type": "room_sensor",
  "temperature": {
     "type": "float",
     "value": 23.2
  },      
  "noise": {
     "type": "integer",
     "value": 35
  }
}

因此,您可以根据需要使用 float 或 double。


推荐阅读