use our deserializer instead of results toXcontent because the source field is differnet from sourceAsMap.
327985
public static String hitsAsStringResult(SearchHits results, MetaSearchResult metaResults) throws IOException {
        if(results == null) return null;
        Object[] searchHits;
        searchHits = new Object[(int) results.getTotalHits()];
        int i = 0;
        for(SearchHit hit : results) {
            HashMap<String,Object> value = new HashMap<>();
            value.put("_id",hit.getId());
            value.put("_type", hit.getType());
            value.put("_score", hit.getScore());
            value.put("_source", hit.getSourceAsMap());
            searchHits[i] = value;
            i++;
        }
        HashMap<String,Object> hits = new HashMap<>();
        hits.put("total",results.getTotalHits());
        hits.put("max_score",results.getMaxScore());
        hits.put("hits",searchHits);
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).prettyPrint();
        builder.startObject();
        builder.field("took", metaResults.getTookImMilli());
        builder.field("timed_out",metaResults.isTimedOut());
        builder.field("_shards", ImmutableMap.of("total", metaResults.getTotalNumOfShards(),
                "successful", metaResults.getSuccessfulShards()
                , "failed", metaResults.getFailedShards()));
        builder.field("hits",hits) ;
        builder.endObject();
        return BytesReference.bytes(builder).utf8ToString();
    }
660509
def _deserialize(self, value, attr, data, **kwargs):
        """"""
        if not value:  # falsy values are invalid
            self.fail('invalid')
        try:
            return utils.from_iso_time(value)
        except (AttributeError, TypeError, ValueError):
            self.fail('invalid')
825726
static Map<String, ?> buildSourceByJsonMapper(Object sourceObject) {
        try {
            return JsonMapper.convertValue(sourceObject, MAP_TYPE_REFERENCE);
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndThrowRuntimeEx(log, e,
                    "buildSourceByJsonMapper", sourceObject);
        }
    }
998140
def deserialize(self, to_deserialize: PrimitiveJsonType) \
            -> Optional[Union[SerializableType, List[SerializableType]]]:
        
        if to_deserialize is None:
            # Implements #17
            return None
        elif isinstance(to_deserialize, List):
            deserialized = []
            for item in to_deserialize:
                item_deserialized = self.deserialize(item)
                deserialized.append(item_deserialized)
            return deserialized
        else:
            mappings_not_set_in_constructor = []    # type: List[PropertyMapping]

            init_kwargs = dict()    # type: Dict[str, Any]
            for mapping in self._property_mappings:
                if mapping.object_constructor_parameter_name is not None:
                    value = mapping.serialized_property_getter(to_deserialize)
                    if not (mapping.optional and value is None):
                        decoded_value = self._deserialize_property_value(value, mapping.deserializer_cls)
                        if isinstance(decoded_value, list):
                            collection = mapping.collection_factory(decoded_value)
                            decoded_value = collection

                        argument = mapping.object_constructor_argument_modifier(decoded_value)
                        init_kwargs[mapping.object_constructor_parameter_name] = argument
                else:
                    mappings_not_set_in_constructor.append(mapping)

            decoded = self._deserializable_cls(**init_kwargs)
            assert type(decoded) == self._deserializable_cls

            for mapping in mappings_not_set_in_constructor:
                assert mapping.object_constructor_parameter_name is None
                if mapping.serialized_property_getter is not None and mapping.object_property_setter is not None:
                    value = mapping.serialized_property_getter(to_deserialize)
                    if not (mapping.optional and value is None):
                        decoded_value = self._deserialize_property_value(value, mapping.deserializer_cls)
                        if isinstance(decoded_value, list):
                            collection = mapping.collection_factory(decoded_value)
                            decoded_value = collection

                        mapping.object_property_setter(decoded, decoded_value)

            return decoded
1154444
public <T> void remapField(Class<T> type, String fromJson, String toJava) {
		JsonReaderI<T> map = this.getMapper(type);
		if (!(map instanceof MapperRemapped)) {
			map = new MapperRemapped<T>(map);
			registerReader(type, map);
		}
		((MapperRemapped<T>) map).renameField(fromJson, toJava);
	}
662944
void readFields(ITuple tuple, Schema schema, Deserializer[] customDeserializers) throws IOException {
		// Set default values / clean values if there are "new fields"
		for(Field field: newFields) {
			tuple.set(field.getName(), field.getDefaultValue());
		}
		
		// If there are fields with nulls, read the bit field and set the values that are null
		if(schema.containsNullableFields()) {
			List<Integer> nullableFields = schema.getNullableFieldsIdx();
			nullsAbsolute.ensureSize(schema.getFields().size());
			nullsAbsolute.clear(nullableFields);
			nullsRelative.deser(input);
			for(int i = 0; i < nullableFields.size(); i++) {
				if(nullsRelative.isSet(i)) {
					int field = backwardsCompatibleIndex(nullableFields.get(i));
					if(field != UNUSED) {
						tuple.set(field, null);
					}
					nullsAbsolute.flags[nullableFields.get(i)] = true;
				}
			}
		}

		// Field by field deserialization
		for(int index = 0; index < schema.getFields().size(); index++) {
			Deserializer customDeser = customDeserializers[index];
			Field field = schema.getField(index);

			// Nulls control
			if(field.isNullable() && nullsAbsolute.flags[index]) {
				// Null field. Nothing to deserialize.
				continue;
			}

			/*
			 * If we configured the Deserializer to use two Schemas,
			 * this will give us the real index for the destination Tuple.
			 * If it gives "UNUSED" it means the field being read is not used.
			 * We will deal with this depending on wether we read a primitive field or 
			 * a complex data type.
			 */
			int idx = backwardsCompatibleIndex(index);

			switch(field.getType()) {
			case INT:
				int iVal = WritableUtils.readVInt(input);
				if(idx != UNUSED) {
					tuple.set(idx, iVal);
				} // If the primitive field is not used we just don't set it
				break;
			case LONG:
				long lVal = WritableUtils.readVLong(input);
				if(idx != UNUSED) {
					tuple.set(idx, lVal);
				} // If the primitive field is not used we just don't set it
				break;
			case DOUBLE:
				double dVal = input.readDouble();
				if(idx != UNUSED) {
					tuple.set(idx, dVal);
				} // If the primitive field is not used we just don't set it
				break;
			case FLOAT:
				float fVal = input.readFloat();
				if(idx != UNUSED) {
					tuple.set(idx, fVal);
				} // If the primitive field is not used we just don't set it
				break;
			case STRING:
				if(idx == UNUSED) {
					// The field is unused so we use a private cached Tuple for skipping its bytes
					readUtf8(input, cachedReadTuple(), index);
				} else {
					readUtf8(input, tuple, idx);
				}
				break;
			case BOOLEAN:
				byte b = input.readByte();
				if(idx != UNUSED) {
					tuple.set(idx, (b != 0));
				} // If the primitive field is not used we just don't set it
				break;
			case ENUM:
				if(idx == UNUSED) {
					// The field is unused so we use a private cached Tuple for skipping its bytes
					readEnum(input, cachedReadTuple(), field.getObjectClass(), index);
				} else {
					readEnum(input, tuple, field.getObjectClass(), idx);
				}
				break;
			case BYTES:
				if(idx == UNUSED) {
					// The field is unused so we use a private cached Tuple for skipping its bytes
					readBytes(input, cachedReadTuple(), index);
				} else {
					readBytes(input, tuple, idx);
				}
				break;
			case OBJECT:
				if(idx == UNUSED) {
					// The field is unused so we use a private cached Tuple for skipping its bytes
					readCustomObject(input, cachedReadTuple(), field.getObjectClass(), index, customDeser);
				} else {
					readCustomObject(input, tuple, field.getObjectClass(), idx, customDeser);
				}
				break;
			default:
				throw new IOException("Not supported type:" + field.getType());
			}
		}
	}
815375
def deserialize_namespace(data):
    ''' 
    '''
    if isinstance(data, bytes):
        data = data.decode('utf-8')
    kvs = data.split()
    uri_to_prefix = {}
    for kv in kvs:
        i = kv.rfind(':')
        if i == -1:
            raise ValueError('no colon in namespace '
                             'field {}'.format(repr(kv)))
        uri, prefix = kv[0:i], kv[i + 1:]
        if not is_valid_schema_uri(uri):
            # Currently this can't happen because the only invalid URIs
            # are those which contain a space
            raise ValueError(
                'invalid URI {} in namespace '
                'field {}'.format(repr(uri), repr(kv)))
        if not is_valid_prefix(prefix):
            raise ValueError(
                'invalid prefix {} in namespace field'
                ' {}'.format(repr(prefix), repr(kv)))
        if uri in uri_to_prefix:
            raise ValueError(
                'duplicate URI {} in '
                'namespace {}'.format(repr(uri), repr(data)))
        uri_to_prefix[uri] = prefix
    return Namespace(uri_to_prefix)
1213836
@Override
  public void parse(String contents) throws SourceMapParseException {
    SourceMapObject sourceMapObject = SourceMapObjectParser.parse(contents);
    parse(sourceMapObject, null);
  }
436882
static Map<SerializedField, Object> fieldsDelta(Map<SerializedField, Object> base,
            Map<SerializedField, Object> child) {
        Map<SerializedField, Object> m = new EnumMap<SerializedField, Object>(child);

        for (Map.Entry<SerializedField, Object> baseEntry : base.entrySet()) {
            SerializedField f = baseEntry.getKey();
            if (m.containsKey(f) && ConfigImplUtil.equalsHandlingNull(baseEntry.getValue(), m.get(f))) {
                // if field is unchanged, just remove it so we inherit
                m.remove(f);
            } else if (!m.containsKey(f)) {
                // if field has been removed, we have to add a deletion entry
                switch (f) {
                case ORIGIN_DESCRIPTION:
                    throw new ConfigException.BugOrBroken("origin missing description field? " + child);
                case ORIGIN_LINE_NUMBER:
                    m.put(SerializedField.ORIGIN_LINE_NUMBER, -1);
                    break;
                case ORIGIN_END_LINE_NUMBER:
                    m.put(SerializedField.ORIGIN_END_LINE_NUMBER, -1);
                    break;
                case ORIGIN_TYPE:
                    throw new ConfigException.BugOrBroken("should always be an ORIGIN_TYPE field");
                case ORIGIN_URL:
                    m.put(SerializedField.ORIGIN_NULL_URL, "");
                    break;
                case ORIGIN_RESOURCE:
                    m.put(SerializedField.ORIGIN_NULL_RESOURCE, "");
                    break;
                case ORIGIN_COMMENTS:
                    m.put(SerializedField.ORIGIN_NULL_COMMENTS, "");
                    break;
                case ORIGIN_NULL_URL: // FALL THRU
                case ORIGIN_NULL_RESOURCE: // FALL THRU
                case ORIGIN_NULL_COMMENTS:
                    throw new ConfigException.BugOrBroken("computing delta, base object should not contain " + f + " "
                            + base);
                case END_MARKER:
                case ROOT_VALUE:
                case ROOT_WAS_CONFIG:
                case UNKNOWN:
                case VALUE_DATA:
                case VALUE_ORIGIN:
                    throw new ConfigException.BugOrBroken("should not appear here: " + f);
                }
            } else {
                // field is in base and child, but differs, so leave it
            }
        }

        return m;
    }
690958
@Override
	public ConcurrentMap<String, Object> deserializeAttributes(final byte[] in) {
		final InputStreamReader inputStream = new InputStreamReader( new ByteArrayInputStream( in ) );
		if (LOG.isDebugEnabled()) {
		    LOG.debug("deserialize the stream");
		}
		try {
			return deserializer.deserializeInto(inputStream, new ConcurrentHashMap<String, Object>());
		} catch( final RuntimeException e) {
			LOG.warn("Caught Exception deserializing JSON "+e);
			throw new TranscoderDeserializationException(e);
		}
	}
88192
@Override
	public Object deserialize(Writable arg0) throws SerDeException {
		// check for null
		if ((arg0 == null) || (arg0 instanceof NullWritable)) {
			return null;
		}
		if (!(arg0 instanceof SpreadSheetCellDAO)) {
			throw new SerDeException("Table does not contain objects of type SpreadSheetCellDAO. Did you use the ExcelCellInputFormat of HadoopOffice?");
		}
		String[] spreadSheetCellRow = new String[5];
		SpreadSheetCellDAO obj = (SpreadSheetCellDAO)arg0;
		spreadSheetCellRow[0] = obj.getFormattedValue();
		spreadSheetCellRow[1] = obj.getComment();
		spreadSheetCellRow[2] = obj.getFormula();
		spreadSheetCellRow[3] = obj.getAddress();
		spreadSheetCellRow[4] = obj.getSheetName();
		return spreadSheetCellRow;
	}
667997
@SuppressWarnings("unchecked")
    @Override
    public <T> T deserialize(byte[] content, Class<T> clazz) throws SerializerException {
        validateString(clazz);
        return (T) new String(content, Charsets.UTF_8);
    }
1127022
static StructrTypeDefinition deserialize(final StructrSchemaDefinition root, final String name, final Map<String, Object> source) {

		final Map<String, StructrPropertyDefinition> deserializedProperties = new TreeMap<>();
		final Map<String, StructrMethodDefinition> deserializedMethods      = new TreeMap<>();
		final StructrTypeDefinition typeDefinition                          = StructrTypeDefinition.determineType(root, name, source);
		final Map<String, Object> properties                                = (Map)source.get(JsonSchema.KEY_PROPERTIES);
		final List<String> requiredPropertyNames                            = (List)source.get(JsonSchema.KEY_REQUIRED);
		final Map<String, Object> views                                     = (Map)source.get(JsonSchema.KEY_VIEWS);
		final Map<String, String> viewOrder                                 = (Map)source.get(JsonSchema.KEY_VIEW_ORDER);
		final Map<String, Object> methods                                   = (Map)source.get(JsonSchema.KEY_METHODS);

		if (properties != null) {

			for (final Entry<String, Object> entry : properties.entrySet()) {

				final String propertyName = entry.getKey();
				final Object value        = entry.getValue();

				if (value instanceof Map) {

					final StructrPropertyDefinition property = StructrPropertyDefinition.deserialize(typeDefinition, propertyName, (Map)value);
					if (property != null) {

						deserializedProperties.put(property.getName(), property);
						typeDefinition.getProperties().add(property);
					}

				} else {

					throw new IllegalStateException("Invalid JSON property definition for property " + propertyName + ", expected object.");
				}
			}
		}

		if (requiredPropertyNames != null) {

			for (final String requiredPropertyName : requiredPropertyNames) {

				// set required properties
				final StructrPropertyDefinition property = deserializedProperties.get(requiredPropertyName);
				if (property != null) {

					property.setRequired(true);

				} else {

					throw new IllegalStateException("Required property " + requiredPropertyName + " not defined for type " + typeDefinition.getName() + ".");
				}
			}
		}

		if (views != null) {

			for (final Entry<String, Object> entry : views.entrySet()) {

				final String viewName = entry.getKey();
				final Object value    = entry.getValue();

				if (value instanceof List) {

					final Set<String> viewProperties = new TreeSet<>((List)value);
					typeDefinition.getViews().put(viewName, viewProperties);

				} else {

					throw new IllegalStateException("View definition " + viewName + " must be of type array.");
				}
			}
		}

		if (viewOrder != null) {

			typeDefinition.getViewOrder().putAll(viewOrder);
		}

		if (methods != null) {

			for (final Entry<String, Object> entry : methods.entrySet()) {

				final String methodName = entry.getKey();
				final Object value      = entry.getValue();

				if (value instanceof Map) {

					final StructrMethodDefinition method = StructrMethodDefinition.deserialize(typeDefinition, methodName, (Map)value);
					if (method != null) {

						deserializedMethods.put(method.getName(), method);
						typeDefinition.getMethods().add(method);
					}

				} else if (value instanceof Collection) {

					// more than on method with the same name exists..
					final Collection<Map<String, Object>> methodList = (Collection)value;

					for (final Map<String, Object> map : methodList) {

						final StructrMethodDefinition method = StructrMethodDefinition.deserialize(typeDefinition, methodName, map);
						if (method != null) {

							deserializedMethods.put(method.getName(), method);
							typeDefinition.getMethods().add(method);
						}
					}

				} else {

					throw new IllegalStateException("Method definition " + methodName + " must be of type string or map.");
				}
			}
		}

		final Object isAbstractValue = source.get(JsonSchema.KEY_IS_ABSTRACT);
		if (isAbstractValue != null && Boolean.TRUE.equals(isAbstractValue)) {

			typeDefinition.setIsAbstract();
		}

		final Object isInterfaceValue = source.get(JsonSchema.KEY_IS_INTERFACE);
		if (isInterfaceValue != null && Boolean.TRUE.equals(isInterfaceValue)) {

			typeDefinition.setIsInterface();
		}

		final Object isBuiltinType = source.get(JsonSchema.KEY_IS_BUILTIN_TYPE);
		if (isBuiltinType != null && Boolean.TRUE.equals(isBuiltinType)) {

			typeDefinition.setIsBuiltinType();
		}

		final Object categoryValue = source.get(JsonSchema.KEY_CATEGORY);
		if (categoryValue != null) {

			typeDefinition.setCategory(categoryValue.toString());
		}

		return typeDefinition;
	}
1164650
@SuppressWarnings({ "unchecked", "rawtypes" })
	private void mapToMap(Map source, Map dest) {
		if (null != dest && null != source) {
			dest.putAll(source);
		}
	}
1220477
private static void parseRenameFile(List<String> lines, URL url, Map<Class<?>, SerDeserializer> map) {
        // format allows multiple [deserializers] so file can be merged
        boolean deserializers = false;
        for (String line : lines) {
            try {
                if (line.equals("[deserializers]")) {
                    deserializers = true;
                } else if (deserializers) {
                    int equalsPos = line.indexOf('=');
                    String beanName = equalsPos >= 0 ? line.substring(0, equalsPos).trim() : line;
                    String deserName = equalsPos >= 0 ? line.substring(equalsPos + 1).trim() : line;
                    registerFromClasspath(beanName, deserName, map);
                } else {
                    throw new IllegalArgumentException("JodaBeans.ini must start with [deserializers]");
                }
            } catch (Exception ex) {
                System.err.println("ERROR: Invalid JodaBeans.ini: " + url + ": " + ex.getMessage());
            }
        }
    }
752478
private void _deserializeQueryField(Query query, Element field) throws PageException, ConverterException {
	String name = field.getAttribute("name");
	NodeList list = field.getChildNodes();
	int len = list.getLength();
	int count = 0;
	for (int i = 0; i < len; i++) {
	    Node node = list.item(i);
	    if (node instanceof Element) {
		query.setAt(KeyImpl.init(name), ++count, _deserialize((Element) node));
	    }
	}

    }
986902
private StringBuilder sourceControl(StringBuilder mapping){
		
		if(getMts() == ALL_FIELDS && !sourceType().isPrimitive()){
			StringBuilder write = write("   if(",getSource(),"!=null){",newLine,
										      sharedCode(mapping)	   ,newLine,
										"   }");
			
			if(!destinationType().isPrimitive() && !avoidSet)
					write.append(write("else{"					   ,newLine,
										 setDestination("null")    ,newLine,
										"   }"					   ,newLine));
			else    write.append(newLine);
			
			return write;
		} 
		else return write(sharedCode(mapping),newLine);
	}