2016-04-20 4 views
1

Мы нашли проблему с attributesFormat=object при тестировании приложения Tourguide https://github.com/Fiware/tutorials.TourGuide-AppInvalid JSON при attributesFormat = объект используется в Tourguide

Если выполнить следующий запрос:

curl <cb_host>:<cb_port>/v1/contextEntities/type/Restaurant/id/Elizalde -s -S --header 'Content-Type: application/json' --header 'x-auth-token:<token>' --header 'Fiware-service: tourguide' --header 'Accept: application/json' 

мы получаем это действительный JSON:

{ 
    "contextElement" : { 
    "type" : "Restaurant", 
    "isPattern" : "false", 
    "id" : "Elizalde", 
    "attributes" : [ 
     { 
     "name" : "address", 
     "type" : "", 
     "value" : { 
      "type" : "postalAddress", 
      "streetAddress" : "Cuesta de las Cabras Aldapa 2", 
      "addressRegion" : "Araba", 
      "addressLocality" : "Alegría-Dulantzi", 
      "postalCode" : "01240" 
     } 
     }, 
     { 
     "name" : "aggregateRating", 
     "type" : "", 
     "value" : { 
      "reviewCount" : 1, 
      "ratingValue" : 3 
     } 
     }, 
     { 
     "name" : "capacity", 
     "type" : "PropertyValue", 
     "value" : 120, 
     "metadatas" : [ 
      { 
      "name" : "name", 
      "type" : "", 
      "value" : "capacity" 
      } 
     ] 
     }, 
     { 
     "name" : "department", 
     "type" : "", 
     "value" : "Franchise3" 
     }, 
     { 
     "name" : "description", 
     "type" : "", 
     "value" : "Restaurante de estilo sidrería ubicado en Alegria-Dulantzi. Además de su menú del día y carta, también ofrece menú de sidrería. El menú del día cuesta 9 euros. Los fines de semana la especialidad de la casa son las alubias con sacramentos. En lo que a bebidas se refiere, hay una amplia selección además de la sidra. Cabe destacar que se puede hacer txotx. La capacidad del establecimiento es de 50 personas pero la sidrería no dispone de aparcamiento.%5cn%5cnHORARIO: %5cn%5cnLunes a domingo: 9:00-17:00 y 19:00-23:00." 
     }, 
     { 
     "name" : "occupancyLevels", 
     "type" : "PropertyValue", 
     "value" : 0, 
     "metadatas" : [ 
      { 
      "name" : "timestamp", 
      "type" : "", 
      "value" : "" 
      }, 
      { 
      "name" : "name", 
      "type" : "", 
      "value" : "occupancyLevels" 
      } 
     ] 
     }, 
     { 
     "name" : "position", 
     "type" : "coords", 
     "value" : "42.8404625, -2.5123277", 
     "metadatas" : [ 
      { 
      "name" : "location", 
      "type" : "string", 
      "value" : "WGS84" 
      } 
     ] 
     }, 
     { 
     "name" : "priceRange", 
     "type" : "", 
     "value" : 0 
     }, 
     { 
     "name" : "telephone", 
     "type" : "", 
     "value" : "945 400 868" 
     } 
    ] 
    }, 
    "statusCode" : { 
    "code" : "200", 
    "reasonPhrase" : "OK" 
    } 
} 

Но если мы будем использовать attributesFormat = объект:

curl <cb_host>:<cb_port>/v1/contextEntities/type/Restaurant/id/Elizalde?attributesFormat=object -s -S --header 'Content-Type: application/json' --header 'x-auth-token:<token>' --header 'Fiware-service: tourguide' --header 'Accept: application/json' 

мы получаем это недопустимое JSON:

{ 
    "contextElement": { 
     "type": "Restaurant", 
     "isPattern": "false", 
     "id": "Elizalde", 
     "attributes": { 
      "address": { 
       "type": "", 
       "value": { 
        "type": "postalAddress", 
        "streetAddress": "Cuesta de las Cabras Aldapa 2", 
        "addressRegion": "Araba", 
        "addressLocality": "Alegría-Dulantzi", 
        "postalCode": "01240" 
       } 
      }, 
      "aggregateRating": { 
       "type": "", 
       "value": { 
        "reviewCount": 1, 
        "ratingValue": 3 
       } 
      }, 
      "capacity": { 
       "type": "PropertyValue", 
       "120", 
       "metadatas": [{ 
        "name": "name", 
        "type": "", 
        "value": "capacity" 
       }] 
      }, 
      "department": { 
       "type": "", 
       "value": "Franchise3" 
      }, 
      "description": { 
       "type": "", 
       "value": "Restaurante de estilo sidrería ubicado en Alegria-Dulantzi. Además de su menú del día y carta, también ofrece menú de sidrería. El menú del día cuesta 9 euros. Los fines de semana la especialidad de la casa son las alubias con sacramentos. En lo que a bebidas se refiere, hay una amplia selección además de la sidra. Cabe destacar que se puede hacer txotx. La capacidad del establecimiento es de 50 personas pero la sidrería no dispone de aparcamiento.%5cn%5cnHORARIO: %5cn%5cnLunes a domingo: 9:00-17:00 y 19:00-23:00." 
      }, 
      "occupancyLevels": { 
       "type": "PropertyValue", 
       "0", 
       "metadatas": [{ 
        "name": "timestamp", 
        "type": "", 
        "value": "" 
       }, { 
        "name": "name", 
        "type": "", 
        "value": "occupancyLevels" 
       }] 
      }, 
      "position": { 
       "type": "coords", 
       "value": "42.8404625, -2.5123277", 
       "metadatas": [{ 
        "name": "location", 
        "type": "string", 
        "value": "WGS84" 
       }] 
      }, 
      "priceRange": { 
       "type": "", 
       "0" 
      }, 
      "telephone": { 
       "type": "", 
       "value": "945 400 868" 
      } 
     } 
    }, 
    "statusCode": { 
     "code": "200", 
     "reasonPhrase": "OK" 
    } 
} 

Шаги к размножению:

Информация о ORION версии:

<orion> 
    <version>0.28.0</version> 
    <uptime>0 d, 1 h, 12 m, 25 s</uptime> 
    <git_hash>aaf8020a5de680b6d7e0c00c70cf425bcc4f39c8</git_hash> 
    <compile_time>Mon Mar 21 13:20:37 UTC 2016</compile_time> 
    <compiled_by>root</compiled_by> 
    <compiled_in>838a42ae8431</compiled_in> 
</orion> 
+0

Не могли бы вы изменить свой вопрос, чтобы добавить версию Orion, которую вы используете, пожалуйста? То есть 'GET/version' в API Orion. Благодаря! – fgalan

ответ

1

Это связано с ошибкой с attributeFormat=object рендеринга в Orion 0.28.0. Ошибка будет исправлена ​​для Orion 1.1.0, которая будет выпущена к концу апреля 2016 года (сейчас она будет объединена в ветку разработки, это the PR, если вы хотите отслеживать прогресс).

+0

Спасибо, мы будем следить за PR. –

+0

Пожалуйста, не забывайте поднимать и отвечать на ответ (не только для подачи моего эго;), но и для того, чтобы разъяснять другим пользователям, что этот ответ правильный). – fgalan

Смежные вопросы