[Fiware-ngsi] JSON rendering proposal

Salvatore Longo Salvatore.Longo at neclab.eu
Tue Sep 17 17:59:03 CEST 2013


Dear All,
I agree with Sergio, the TI implementation is very compact and there are many fields missing . 
I think that the implementation should be strictly related to the NGSI binding. One example will be:

JSON query context Response:
{
  "contextElement" : {
    "entityId" : {
      "id" : "LivingRoom1",
      "type" : "room",
      "isPattern" : false
    },
    "attributeDomainName" : "Test",
    "contextAttributeList" : [ {
      "name" : "indoorTemperature",
      "type" : "temperature",
      "contextValue" : "20",
      "metaData" : [ {
        "name" : "accuracyTemp",
        "type" : "accuracy",
        "value" : "20"
      } ]
    }, {
      "name" : "outdoorTemperature",
      "type" : "temperature",
      "contextValue" : "20",
      "metaData" : [ {
        "name" : "accuracyTemp",
        "type" : "accuracy",
        "value" : 20"
      } ]
    } ],
    "domainMetadata" : [ ]
  },
  "statusCode" : {
    "code" : 200,
    "reasonPhrase" : "Ok",
    "details" : "aaa"
  }
}

We have in mind for the IoT Broker to support JSON and XML format so I think it is important, also for the users, to keep the same format and try to follow as much as we can the NGSI specification.

Best Regards,
 - Salvatore Longo

________________________________

Salvatore Longo
Software Engineer
NEC Europe Ltd.
Kurfürsten-Anlage 36
D-69115 Heidelberg

Tel.  +49/(0) 62 21/43 42 - 246
Fax. +49/(0) 62 21/43 42 - 115 
E-Mail: Salvatore.longo at neclab.eu

NEC Europe Limited
Registered Office: NEC House,
1 Victoria Road, London W3 6BL
Registered in England 2832014

________________________________


-----Original Message-----
From: Rolando Sergio (Guest) [mailto:sergio.rolando at guest.telecomitalia.it] 
Sent: Dienstag, 17. September 2013 17:14
To: Fermín Galán Márquez; fiware-ngsi at lists.fi-ware.eu; Salvatore Longo; Tobias Jacobs
Cc: Moltchanov Boris; Licciardi Carlo Alberto
Subject: RE: [Fiware-ngsi] JSON rendering proposal

Hi Fermin, and hi all,
At the beginning of our implementation, TI Context Broker supported only JSON, and then XML was added.

The JSON format implemented in TI CB is strictly related to the XML binding specification, preserving every tag in both formats, in order to have easy interoperability.
The XML attributes (as "type" in "entityId" tag) are transformed as a standard JSON field, as shown in the following fragments (and also as assumed in your proposal):

XML:
<entityId type="urn:username">
     <id>urn:username:cristinaF</id>
</entityId>

JSON:
 "entityId": {
       "id": "urn:username:cristinaF",
       "type": "urn:username"
 }

Here is an example of the same UpdateContextRequest message (sorry for the TI-like example :-) ) in both XML and JSON format:

XML:
<updateContextRequest>
    <contextElementList>
        <contextElement>
            <entityId type="urn:username">
               <id>urn:username:cristinaF</id>
            </entityId>
            <contextAttributeList>
                <contextAttribute>
                    <name>cell</name>
                    <contextValue>
                        <cgi>222-1-61101-7065</cgi>
                    </contextValue>
                    <metadata>
                        <contextMetadata>
                            <name>Timestamp</name>
                            <value>2012-06-13T15:04:52+01:00</value>
                        </contextMetadata>
                        <contextMetadata>
                            <name>Expires</name>
                            <value>2012-06-13T15:04:52+01:00</value>
                        </contextMetadata>
                        <contextMetadata>
                            <name>Source</name>
                            <value>teamlife_1.0</value>
                        </contextMetadata>
                    </metadata>
                </contextAttribute>
             </contextAttributeList>
        </contextElement>
    </contextElementList>
    <updateAction>UPDATE</updateAction>
</updateContextRequest>

JSON:
{
  "updateContextRequest": {
    "contextElementList": {
      "contextElement": [
        {
          "entityId": {
            "id": "urn:username:cristinaF",
            "type": "urn:username"
          },
          "contextAttributeList": {
            "contextAttribute": [
              {
                "name": "cell",
                "metadata": {
                  "contextMetadata": [
                    {
                      "name": "Timestamp",
                      "value": "2012-06-13T15:04:52+01:00"
                    },
                    {
                      "name": "Expires",
                      "value": "2012-06-13T15:04:52+01:00"
                    },
                    {
                      "name": "Source",
                      "value": "TeamLife_1.0"
                    }
                  ]
                },
                "contextValue": {
                  "cgi": "222-1-61101-7065"
                }
              }
            ]
          }
        }
      ]
    },
    "updateAction": "UPDATE"
  }
}

Your proposal for JSON binding is more compact, and it would be a great solution if there was no legacy of XML binding, but it is pretty different from the XML binding specification. Specifically, some tags are missing, e.g.:
- first external tag identifying the message type (e.g. "updateContextElement")
- "entity" in updateContextElement message (there is only "id"/"type"/"isPattern", assuming that they are related to the entity)
- tags ending in -List for list of structures.

We have also to consider that the XML binding specification was built based on the standard NGSI specification, and the XML messages strictly match the standard NGSI data structures, so it could be a further reason to preserve it also in JSON.
It would be interesting to know the opinion of Salvatore and Tobias from NEC, who studied and developed the XML binding.

Best regards,
Sergio


-----Original Message-----
From: fiware-ngsi-bounces at lists.fi-ware.eu [mailto:fiware-ngsi-bounces at lists.fi-ware.eu] On Behalf Of Fermín Galán Márquez
Sent: martedì 17 settembre 2013 13.23
To: fiware-ngsi at lists.fi-ware.eu
Subject: [Fiware-ngsi] JSON rendering proposal

Hi,

As previously discussed in this list (see https://lists.fi-ware.eu/private/fiware-ngsi/2013-September/000490.html), please find attached TID's proposal for NGSI JSON rendering. We will start this week implementing JSON support in Orion Context Broker based in it.

Any feedback is highly welcome!

Best regards,

------
Fermín

________________________________

Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo.
This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at:
http://www.tid.es/ES/PAGINAS/disclaimer.aspx



More information about the Fiware-ngsi mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy