Changes between Version 6 and Version 7 of MapGuideRfc158
- Timestamp:
- 04/20/17 06:03:50 (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
MapGuideRfc158
v6 v7 28 28 == Motivation == 29 29 30 All JSON responses from the mapagent are verbatim conversions from their XML counterparts.30 All JSON responses from the mapagent are currently verbatim conversions from their XML counterparts. 31 31 32 32 However this conversion process results in JSON that is quite cumbersome to consume: 33 33 34 * All properties are arrays.35 * All properties arestring values.34 * All converted elements are arrays. 35 * All converted element content are arrays of string values. 36 36 37 This is due to the conversion process not taking the content model (and its data types/element cardinality) into account, taking the lowest common denominator approach. 37 This is due to the XML to JSON conversion process not taking the content model (and its data types/element cardinality) into account, taking the lowest common denominator approach. 38 39 Current client applications that do happen to use the JSON responses provided by the mapagent will most likely be having to employ manual "de-arrayification" of the JSON content and lots of manual string to int/double/boolean parsing to be able to work with the current JSON responses. You can see this in Fusion where there is a lot of initialization work in de-arrayification/{{{parseInt}}}/{{{parseFloat}}} of the ApplicatonDefinition and RuntimeMap JSON responses. 40 41 This is work that client applications do not, and should not have to do. 38 42 39 43 == Proposed Solution == 40 44 41 The MgJsonConvert classthat does the actual XML to JSON conversion will be modified to include a hard-coded list of XML element paths:45 The {{{MgJsonConvert}}} class of the {{{HttpHandler}}} project that does the actual XML to JSON conversion will be modified to include a hard-coded list of XML element paths: 42 46 43 47 * For elements that contain 0 to many elements 44 48 * For elements that are not string data types 45 49 46 During the conversion process, we check the computed XML element path of the element we're converting and check if it is in one of these two lists50 During the conversion process, we check the computed XML element path of the element/attriubte we're converting and check if it is in one of these two lists 47 51 48 52 * If it is in the first list, the element is written as a JSON array … … 54 58 With the new JSON responses, not only are they more simpler to use (not everything is an array and not everything is a string and the content structure is semantically similar to their XML counterparts), but is also much more compact due to the amount of {{{[}}} and {{{"}}} characters we save by not converting everything to string arrays 55 59 56 Fusion will also be updated to take advantage of the new clean JSON responses. 60 Fusion will also be partially updated to take advantage of the new clean JSON responses: 61 62 * For initial runtime map creation ({{{CREATERUNTIMEMAP}}}) 63 * For its selection/tooltip queries ({{{QUERYMAPFEATURES}}}) 64 * ApplicationDefinition parsing will remain as-is because converting this to use clean JSON responses will flow on to having to update *all* current widgets that get created by this parsed appdef to use the clean JSON as well, which is too much effort for the desired payoff. 57 65 58 66 == GeoJSON output == … … 60 68 For the {{{SELECTFEATURES}}} mapagent operation, even with the clean JSON response formatting applied, the JSON response is still near-useless for consumption by client applications. 61 69 62 For this particular operation, if we want the response in JSON, since it includes spatialdata for features it is more practical to return this in GeoJSON format, which is more ubiquitous and more practical for client-application consumption.70 For this particular operation, if we want the response in JSON, since it includes geometric data for features it is more practical to return this in GeoJSON format, which is more ubiquitous and more practical for client-application consumption. 63 71 64 72 To enable this, we'll be adding a new MgGeoJsonWriter utility class to the PlatformBase library to enable easy GeoJSON conversion from feature readers … … 2373 2381 == Implications == 2374 2382 2375 Any time a new schema or schema revision is introduced, this hard-coded listwill have to be updated to know which elements in these new schemas require special processing.2383 Any time a new schema or schema revision is introduced, this hard-coded element path list in {{{MgJsonConvert}}} will have to be updated to know which elements in these new schemas require special processing. 2376 2384 2377 2385 == Test Plan ==