2 * Copyright (C) 2013 HERE Global B.V. All rights reserved.
3 * This software, including documentation, is protected by copyright controlled by
4 * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
5 * storing, adapting or translating, any or all of this material requires the prior
6 * written consent of HERE Global B.V. You may use this
7 * Software in accordance with the terms and conditions defined in the
8 * HERE Location Platform Services Terms and Conditions, available at
9 * http://developer.here.com/terms-conditions-base
11 * As an additional permission to the above, you may distribute Software,
12 * in object code format as part of an Application, according to, and subject to, terms and
13 * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
14 * You may distribute such object code format Application under terms of your choice,
15 * provided that the header and source files of the Software have not been modified.
18 #ifndef JSON_PARSER_H_
19 #define JSON_PARSER_H_
21 #include "common/HereMaps_global.h"
22 #include "finder/Category.h"
23 #include "finder/ContactDetails.h"
24 #include "finder/ExtendedAttribute.h"
25 #include "finder/ImageContent.h"
26 #include "finder/ReviewContent.h"
27 #include "finder/EditorialContent.h"
28 #include "finder/PlaceItem.h"
29 #include "finder/SearchItem.h"
30 #include "finder/PlaceDetails.h"
32 #ifndef TIZEN_MIGRATION
39 #ifdef TIZEN_MIGRATION
40 #include "base/BaseByteBuffer.h"
43 #define JsonArray json_object
44 #define JsonNumber json_object
45 #define JsonObject json_object
46 #define IJsonValue json_object
47 #define JsonBool json_object
49 using namespace Tizen::Maps;
51 using namespace Tizen::Base;
52 using namespace Tizen::Base::Utility;
53 using namespace Tizen::Web::Json;
56 HERE_MAPS_BEGIN_NAMESPACE
71 * Parses Places API Json data.
73 * @ingroup Search / Online / Parser
80 * Parse discover search results.
81 * @param json_stream ByteBuffer.
82 * @param results_page Parsed Discovery query.
83 * @param error A pointer to an object that is populated
84 * with error information should parsing fail.
86 static bool ParseDiscoverySearch( ByteBuffer& buf, DiscoveryReply& results_page, FinderError*& error);
90 * @param json_stream ByteBuffer.
91 * @param place_data Parsed place data.
92 * @param error A pointer to an object that is populated
93 * with error information should parsing fail.
95 static bool ParsePlaceResult( ByteBuffer& buf, PlaceDetails& place_data, FinderError*& error);
99 static void ParseGeocodeSearch( ByteBuffer& json_stream,
100 std::vector< GeoLocation >& results );
102 static void ParseReverseGeocodeSearch( ByteBuffer& json_stream, Address& address );
105 static void ParseTextSuggestions( ByteBuffer& json, std::vector< String >& suggestions );
108 static void ParseDiscoverySearch( IJsonValue* json, DiscoveryReply& results_page );
110 static void ParsePlaceResult( IJsonValue* json, PlaceDetails& place_data );
112 static void ParseAlternativeNames( JsonArray* json_data,
113 PlaceDetails::AlternativeNames& alternative_names );
115 static void ParsePlaceLocation( JsonObject* json_data, GeoLocation& location );
117 static void ParsePosition( JsonObject* json_data, GeoCoordinates& position );
119 static void ParseAddress( JsonObject* json_data, Address& address );
121 #ifdef TIZEN_MIGRATION
122 static void ParseContacts( JsonArray* json_data, ContactDetailsList& contacts );
124 static void ParseContacts( JsonArray* json_data, const String& key,
125 ContactDetailsList& contacts );
127 static void ParseLinkObject( JsonObject* json_data, LinkObject& link_object );
129 static void ParseContacts( JsonArray* json_data, const String& key,
130 ContactDetailsList& contacts );
132 static void ParseLinkObject( IJsonValue* json_data,
133 const char* object_name,
134 LinkObject& link_object );
136 static void ParseLinkObject( JsonObject* json_data, LinkObject& link_object );
138 static void ParseLinkObject( JsonObject* json_data,
139 const char* object_name,
140 LinkObject& link_object );
142 static void ParseRatings( JsonObject* json_data, Ratings& ratings );
144 static void ParseCategories( JsonArray* json_data, CategoryList& categories );
146 static void ParseCategory( JsonObject* json_data, Category& category );
148 static void ParseAttributes( JsonObject* json_data, ExtendedAttributeList& attributes );
150 static void ParseSearchContext( JsonObject* json_data, SearchContext& results_context );
152 static void ParseBbox( JsonObject* json_data, GeoBoundingBox& bbox );
154 static void ParseResultsItemPlace( JsonObject* json_data, PlaceItem& place_result );
156 static void ParseResultsItemSearch( JsonObject* json_data, SearchItem& search_result );
158 static void ParsePlaceRelated( JsonObject* json_data, PlaceDetails& place_data );
160 static void ParsePlaceMedia( JsonObject* json_data, PlaceDetails& place_data );
162 static void ParsePlaceEditorials( JsonObject* json_data, EditorialContentList& editorials );
164 static void ParsePlaceImages( JsonObject* json_data, ImageContentList& images );
166 static void ParsePlaceReviews( JsonObject* json_data, ReviewContentList& reviews );
168 static void ParsePlaceEditorial( JsonObject* json_data, EditorialContent& editorial );
170 static void ParsePlaceImage( JsonObject* json_data, ImageContent& image );
172 static void ParsePlaceReview( JsonObject* json_data, ReviewContent& review );
174 static void ParsePlaceBaseContent( JsonObject* json_data, BaseContent& media );
176 static void TraverseRootNode( ByteBuffer& json_stream, IJsonValue* root );
177 static void ParseCoordinates( IJsonValue* json_location, GeoLocation& loc );
178 static void ParseBoundingBox( IJsonValue* json_location, GeoLocation& loc );
179 static void ParseAddress( IJsonValue* json_location, GeoLocation& loc );
181 static void ParsePlaceResults(JsonArray* pObject, PlaceItemList&, SearchItemList& );
184 static void GetStringValue(JsonObject* pObject, const String& sKey, String& value );
185 static void GetUriValue(JsonObject* pObject, const String& sKey, Uri& uri );
186 static bool GetValuePtr(JsonObject* pObject, const String& sKey, IJsonValue*& pValue );
189 HERE_MAPS_END_NAMESPACE
191 #endif // JSON_PARSER_H_