private CallControlCallResultType parseResult(MultivaluedMap<String, String> queryParams, WebResource resource, boolean returnResult) throws JsonProcessingException, IOException { queryParams.add("output", "json"); Builder builder = resource.queryParams(queryParams).getRequestBuilder(); builder = builder.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); builder = builder.type(javax.ws.rs.core.MediaType.APPLICATION_JSON); builder = builder.cookie(JSESSIONID_WS); String resultStr = builder.get(String.class); ObjectMapper mapper = new ObjectMapper(); mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); JsonNode rootNode = mapper.readTree(resultStr); if(returnResult) { JsonNode ccr = rootNode.path("ExtActionResponse").path("structure").path("CallControlCallResult"); return mapper.readValue(ccr, CallControlCallResultType.class); } else return null; }
private final Collection<Object> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<Object> paramCollection) throws IOException, JsonProcessingException { if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) throw paramDeserializationContext.mappingException(this._collectionType.getRawClass()); JsonDeserializer localJsonDeserializer = this._valueDeserializer; TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer; Object localObject; if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL) localObject = null; while (true) { paramCollection.add(localObject); return paramCollection; if (localTypeDeserializer == null) { localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext); continue; } localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer); } }
public Enum<?> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException, JsonProcessingException { JsonToken localJsonToken = paramJsonParser.getCurrentToken(); if (localJsonToken == JsonToken.VALUE_STRING) { String str = paramJsonParser.getText(); Enum localEnum2 = this._resolver.findEnum(str); if (localEnum2 == null) throw paramDeserializationContext.weirdStringException(this._resolver.getEnumClass(), "value not one of declared Enum instance names"); return localEnum2; } if (localJsonToken == JsonToken.VALUE_NUMBER_INT) { if (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS)) throw paramDeserializationContext.mappingException("Not allowed to deserialize Enum value out of JSON number (disable DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS to allow)"); int i = paramJsonParser.getIntValue(); Enum localEnum1 = this._resolver.getEnum(i); if (localEnum1 == null) throw paramDeserializationContext.weirdNumberException(this._resolver.getEnumClass(), "index value outside legal index range [0.." + this._resolver.lastValidIndex() + "]"); return localEnum1; } throw paramDeserializationContext.mappingException(this._resolver.getEnumClass()); }
private final Collection<String> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection) throws IOException, JsonProcessingException { if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) throw paramDeserializationContext.mappingException(this._collectionType.getRawClass()); JsonDeserializer localJsonDeserializer = this._valueDeserializer; if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL) { localObject = null; paramCollection.add(localObject); return paramCollection; } if (localJsonDeserializer == null); for (Object localObject = paramJsonParser.getText(); ; localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext)) break; }
protected SettableAnyProperty constructAnySetter(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, AnnotatedMethod paramAnnotatedMethod) throws JsonMappingException { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedMethod.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedMethod.getParameterType(1)); BeanProperty.Std localStd = new BeanProperty.Std(paramAnnotatedMethod.getName(), localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedMethod, localStd); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localStd); if (localJsonDeserializer != null) { SettableAnyProperty localSettableAnyProperty = new SettableAnyProperty(localStd, paramAnnotatedMethod, localJavaType2); localSettableAnyProperty.setValueDeserializer(localJsonDeserializer); return localSettableAnyProperty; } return new SettableAnyProperty(localStd, paramAnnotatedMethod, modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localJavaType2, localStd.getName())); }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedField paramAnnotatedField) throws JsonMappingException { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedField.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedField.getGenericType()); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedField, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedField, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedField, localJavaType2, paramString); SettableBeanProperty.FieldProperty localFieldProperty = new SettableBeanProperty.FieldProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); if (localJsonDeserializer != null) localFieldProperty.setValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedField); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) localFieldProperty.setManagedReferenceName(localReferenceProperty.getName()); return localFieldProperty; }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedMethod paramAnnotatedMethod) throws JsonMappingException { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedMethod.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedMethod.getParameterType(0)); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedMethod, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localJavaType2, paramString); SettableBeanProperty.MethodProperty localMethodProperty = new SettableBeanProperty.MethodProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); if (localJsonDeserializer != null) localMethodProperty.setValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedMethod); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) localMethodProperty.setManagedReferenceName(localReferenceProperty.getName()); return localMethodProperty; }
protected CreatorContainer findDeserializerCreators(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription) throws JsonMappingException { boolean bool = paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS); CreatorContainer localCreatorContainer = new CreatorContainer(paramBasicBeanDescription, bool); AnnotationIntrospector localAnnotationIntrospector = paramDeserializationConfig.getAnnotationIntrospector(); if (paramBasicBeanDescription.getType().isConcrete()) { Constructor localConstructor = paramBasicBeanDescription.findDefaultConstructor(); if (localConstructor != null) { if (bool) ClassUtil.checkAndFixAccess(localConstructor); localCreatorContainer.setDefaultConstructor(localConstructor); } } VisibilityChecker localVisibilityChecker1 = paramDeserializationConfig.getDefaultVisibilityChecker(); if (!paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.AUTO_DETECT_CREATORS)) localVisibilityChecker1 = localVisibilityChecker1.withCreatorVisibility(JsonAutoDetect.Visibility.NONE); VisibilityChecker localVisibilityChecker2 = paramDeserializationConfig.getAnnotationIntrospector().findAutoDetectVisibility(paramBasicBeanDescription.getClassInfo(), localVisibilityChecker1); _addDeserializerConstructors(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorContainer); _addDeserializerFactoryMethods(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorContainer); return localCreatorContainer; }
public static CityListCityModel[] readCityList() { List<CityListCityModel> list = new ArrayList<CityListCityModel>(); CityListCityModel cities[]; String json = readAssertsFile("city.json", IndexListviewApplication.getContext()); try { ObjectMapper mapper = new ObjectMapper(); mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); JavaType javaType = mapper.getTypeFactory().constructParametricType(ArrayList.class, CityListCityModel.class); list = mapper.readValue(json.toString(), javaType); } catch (Exception e) { e.printStackTrace(); } cities = list.toArray(new CityListCityModel[list.size()]); return cities; }
@Override public List<Map<Term, String>> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { if (jp.getCurrentToken() == JsonToken.START_ARRAY) { JsonDeserializer<Object> deserializer = ctxt.getDeserializerProvider().findTypedValueDeserializer(ctxt.getConfig(), ctxt.constructType(List.class),null); List<Map<String, String>> verbatimTerms = (List<Map<String, String>>) deserializer.deserialize(jp, ctxt); List<Map<Term, String>> interpretedTerms = Lists.newArrayList(); for (Map<String, String> verbExtension : verbatimTerms) { Map<Term, String> extension = new HashMap<Term, String>(); for (Entry<String, String> entry : verbExtension.entrySet()) { Term term = termFactory.findTerm(entry.getKey()); if (term == null && ctxt.getConfig().isEnabled(Feature.FAIL_ON_UNKNOWN_PROPERTIES)) { throw ctxt.mappingException("Term not found " + entry.getKey()); } extension.put(term, entry.getValue()); } interpretedTerms.add(extension); } return interpretedTerms; } throw ctxt.mappingException("Expected JSON String"); }
public void wrapAndThrow(Throwable paramThrowable, Object paramObject, String paramString, DeserializationContext paramDeserializationContext) { for (Throwable localThrowable = paramThrowable; ((localThrowable instanceof InvocationTargetException)) && (localThrowable.getCause() != null); localThrowable = localThrowable.getCause()); if ((localThrowable instanceof Error)) throw ((Error)localThrowable); if ((paramDeserializationContext == null) || (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.WRAP_EXCEPTIONS))); for (int i = 1; (localThrowable instanceof IOException); i = 0) { if ((i != 0) && ((localThrowable instanceof JsonMappingException))) break label114; throw ((IOException)localThrowable); } if ((i == 0) && ((localThrowable instanceof RuntimeException))) throw ((RuntimeException)localThrowable); label114: throw JsonMappingException.wrapWithPath(localThrowable, paramObject, paramString); }
private final Collection<String> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection) { if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) throw paramDeserializationContext.mappingException(this._collectionType.getRawClass()); JsonDeserializer localJsonDeserializer = this._valueDeserializer; Object localObject; if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL) localObject = null; while (true) { paramCollection.add(localObject); return paramCollection; if (localJsonDeserializer == null) localObject = paramJsonParser.getText(); else localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext); } }
private final Collection<Object> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<Object> paramCollection) { if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) throw paramDeserializationContext.mappingException(this._collectionType.getRawClass()); JsonDeserializer localJsonDeserializer = this._valueDeserializer; TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer; Object localObject; if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL) localObject = null; while (true) { paramCollection.add(localObject); return paramCollection; if (localTypeDeserializer == null) localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext); else localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer); } }
private final String[] handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) { if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { if ((paramJsonParser.getCurrentToken() == JsonToken.VALUE_STRING) && (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) && (paramJsonParser.getText().length() == 0)) return null; throw paramDeserializationContext.mappingException(this._valueClass); } String[] arrayOfString = new String[1]; JsonToken localJsonToken1 = paramJsonParser.getCurrentToken(); JsonToken localJsonToken2 = JsonToken.VALUE_NULL; String str = null; if (localJsonToken1 == localJsonToken2); while (true) { arrayOfString[0] = str; return arrayOfString; str = paramJsonParser.getText(); } }
protected Object mapArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) { if (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.USE_JAVA_ARRAY_FOR_JSON_ARRAY)) return mapArrayToArray(paramJsonParser, paramDeserializationContext); if (paramJsonParser.nextToken() == JsonToken.END_ARRAY) return new ArrayList(4); ObjectBuffer localObjectBuffer = paramDeserializationContext.leaseObjectBuffer(); Object[] arrayOfObject1 = localObjectBuffer.resetAndStart(); int i = 0; Object[] arrayOfObject2 = arrayOfObject1; int j = 0; Object localObject = deserialize(paramJsonParser, paramDeserializationContext); j++; if (i >= arrayOfObject2.length) arrayOfObject2 = localObjectBuffer.appendCompletedChunk(arrayOfObject2); for (int k = 0; ; k = i) { i = k + 1; arrayOfObject2[k] = localObject; if (paramJsonParser.nextToken() != JsonToken.END_ARRAY) break; ArrayList localArrayList = new ArrayList(1 + (j + (j >> 3))); localObjectBuffer.completeAndClearBuffer(arrayOfObject2, i, localArrayList); return localArrayList; } }
public Enum<?> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) { JsonToken localJsonToken = paramJsonParser.getCurrentToken(); Enum localEnum; if (localJsonToken == JsonToken.VALUE_STRING) { String str = paramJsonParser.getText(); localEnum = this._resolver.findEnum(str); if (localEnum == null) throw paramDeserializationContext.weirdStringException(this._resolver.getEnumClass(), "value not one of declared Enum instance names"); } else if (localJsonToken == JsonToken.VALUE_NUMBER_INT) { if (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS)) throw paramDeserializationContext.mappingException("Not allowed to deserialize Enum value out of JSON number (disable DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS to allow)"); int i = paramJsonParser.getIntValue(); localEnum = this._resolver.getEnum(i); if (localEnum == null) throw paramDeserializationContext.weirdNumberException(this._resolver.getEnumClass(), "index value outside legal index range [0.." + this._resolver.lastValidIndex() + "]"); } else { throw paramDeserializationContext.mappingException(this._resolver.getEnumClass()); } return localEnum; }
public StdValueInstantiator(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType) { boolean bool; if (paramDeserializationConfig == null) { bool = false; this._cfgEmptyStringsAsObjects = bool; if (paramJavaType != null) break label41; } label41: for (String str = "UNKNOWN TYPE"; ; str = paramJavaType.toString()) { this._valueTypeDesc = str; return; bool = paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); break; } }
public static KeyDeserializer findStringBasedKeyDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType) { BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspect(paramJavaType); Constructor localConstructor = localBasicBeanDescription.findSingleArgConstructor(new Class[] { String.class }); if (localConstructor != null) { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) ClassUtil.checkAndFixAccess(localConstructor); return new StdKeyDeserializer.StringCtorKeyDeserializer(localConstructor); } Method localMethod = localBasicBeanDescription.findFactoryMethod(new Class[] { String.class }); if (localMethod != null) { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) ClassUtil.checkAndFixAccess(localMethod); return new StdKeyDeserializer.StringFactoryKeyDeserializer(localMethod); } return null; }
protected void addInjectables(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, BeanDeserializerBuilder paramBeanDeserializerBuilder) { Map localMap = paramBasicBeanDescription.findInjectables(); if (localMap != null) { boolean bool = paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS); Iterator localIterator = localMap.entrySet().iterator(); while (localIterator.hasNext()) { Map.Entry localEntry = (Map.Entry)localIterator.next(); AnnotatedMember localAnnotatedMember = (AnnotatedMember)localEntry.getValue(); if (bool) localAnnotatedMember.fixAccess(); paramBeanDeserializerBuilder.addInjectable(localAnnotatedMember.getName(), paramBasicBeanDescription.resolveType(localAnnotatedMember.getGenericType()), paramBasicBeanDescription.getClassAnnotations(), localAnnotatedMember, localEntry.getKey()); } } }
protected ValueInstantiator constructDefaultValueInstantiator(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription) { boolean bool = paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS); CreatorCollector localCreatorCollector = new CreatorCollector(paramBasicBeanDescription, bool); AnnotationIntrospector localAnnotationIntrospector = paramDeserializationConfig.getAnnotationIntrospector(); if (paramBasicBeanDescription.getType().isConcrete()) { AnnotatedConstructor localAnnotatedConstructor = paramBasicBeanDescription.findDefaultConstructor(); if (localAnnotatedConstructor != null) { if (bool) ClassUtil.checkAndFixAccess(localAnnotatedConstructor.getAnnotated()); localCreatorCollector.setDefaultConstructor(localAnnotatedConstructor); } } VisibilityChecker localVisibilityChecker1 = paramDeserializationConfig.getDefaultVisibilityChecker(); VisibilityChecker localVisibilityChecker2 = paramDeserializationConfig.getAnnotationIntrospector().findAutoDetectVisibility(paramBasicBeanDescription.getClassInfo(), localVisibilityChecker1); _addDeserializerFactoryMethods(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorCollector); _addDeserializerConstructors(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorCollector); return localCreatorCollector.constructValueInstantiator(paramDeserializationConfig); }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedField paramAnnotatedField) { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedField.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedField.getGenericType()); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedField, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedField, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedField, localJavaType2, paramString); Object localObject = new SettableBeanProperty.FieldProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); if (localJsonDeserializer != null) localObject = ((SettableBeanProperty)localObject).withValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedField); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) ((SettableBeanProperty)localObject).setManagedReferenceName(localReferenceProperty.getName()); return localObject; }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedMethod paramAnnotatedMethod) { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedMethod.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedMethod.getParameterType(0)); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedMethod, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localJavaType2, paramString); Object localObject = new SettableBeanProperty.MethodProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); if (localJsonDeserializer != null) localObject = ((SettableBeanProperty)localObject).withValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedMethod); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) ((SettableBeanProperty)localObject).setManagedReferenceName(localReferenceProperty.getName()); return localObject; }
/** * 获取统一的ObjectMapper. * * @return 统一的ObjectMapper. */ public static ObjectMapper getJsonObjectMapper() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); return objectMapper; }
@Override protected <T> T createRESTClientProxy(String apiUrl, Class<T> proxy) { URI i = null; try { i = new URI(apiUrl); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } ResteasyClientBuilder builder = new ResteasyClientBuilder(); builder.connectionCheckoutTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); builder.socketTimeout(CONNECTION_SETUP_TO, TimeUnit.SECONDS); builder.httpEngine(new URLConnectionEngine()); ResteasyProviderFactory.getInstance().register(builder); ResteasyClient client = builder.build(); client.register(new ClientRequestFilter() { @Override public void filter(ClientRequestContext requestContext) throws IOException { requestContext.getHeaders().add("User-Agent", getImplementationName() + "=" + getVersion()); } }); ObjectMapper mapper = new ObjectMapper(); JacksonJaxbJsonProvider jaxbProvider = new JacksonJaxbJsonProvider(mapper, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS); mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector()); mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); builder.register(jaxbProvider); builder.register(proxy); ResteasyWebTarget resteasyWebTarget = client.target(i); return resteasyWebTarget.proxy(proxy); }
public LinkedHashMap<String, MetaDataElement> getMetadataFile(User user, String filename) { String username = user.getOrganization().getName()+":"+user.getMail(); this.selectCollection(DB_METADATA); DBCursor cursor = table.find(new BasicDBObject("username", username), new BasicDBObject(ARRAY_METADATA, new BasicDBObject("$elemMatch", new BasicDBObject("filename.value", filename)))); List<LinkedHashMap<String, MetaDataElement>> resultSet = new ArrayList<LinkedHashMap<String, MetaDataElement>>(); ObjectMapper objMapper = new ObjectMapper(); // Prevents mapper from throwing exception on fields that are not present in given TypeReference // In this case returned JSON has field "class" that is not found in MetaDataElement class // Note: This is for jackson version 1.x.x. For 2.x use DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES objMapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); while (cursor.hasNext()) { // Deserializes returned JSON to given data structure resultSet = objMapper.convertValue(cursor.next().get(ARRAY_METADATA), new TypeReference<List<LinkedHashMap<String,MetaDataElement>>>() { }); } if (resultSet == null || resultSet.isEmpty()) { return new LinkedHashMap<String, MetaDataElement>(); } // Remove filename entry. Can be left in if needed. resultSet.get(0).remove("filename"); cursor.close(); return resultSet.get(0); }
public ASCCallControlClient(String host, int port) { ENDPOINT = "http://" + host + ":" + port + "/"; clientConfig = new DefaultClientConfig(); ObjectMapper mapper = new ObjectMapper(); mapper.configure(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); JacksonJsonProvider provider = new JacksonJsonProvider(mapper); clientConfig.getSingletons().add(provider); }
public JsonDeserializer<?> createCollectionDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, CollectionType paramCollectionType, BeanProperty paramBeanProperty) throws JsonMappingException { CollectionType localCollectionType1 = (CollectionType)mapAbstractType(paramDeserializationConfig, paramCollectionType); Object localObject = localCollectionType1.getRawClass(); BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations((Class)localObject); JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty); if (localJsonDeserializer1 != null) return localJsonDeserializer1; CollectionType localCollectionType2 = (CollectionType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localCollectionType1, null); JavaType localJavaType = localCollectionType2.getContentType(); JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType.getValueHandler(); TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType.getTypeHandler(); if (localTypeDeserializer == null) localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType, paramBeanProperty); JsonDeserializer localJsonDeserializer3 = _findCustomCollectionDeserializer(localCollectionType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localTypeDeserializer, localJsonDeserializer2); if (localJsonDeserializer3 != null) return localJsonDeserializer3; if (localJsonDeserializer2 == null) { if (EnumSet.class.isAssignableFrom((Class)localObject)) return new EnumSetDeserializer(constructEnumResolver(localJavaType.getRawClass(), paramDeserializationConfig)); localJsonDeserializer2 = paramDeserializerProvider.findValueDeserializer(paramDeserializationConfig, localJavaType, paramBeanProperty); } if ((localCollectionType2.isInterface()) || (localCollectionType2.isAbstract())) { Class localClass = (Class)_collectionFallbacks.get(((Class)localObject).getName()); if (localClass == null) throw new IllegalArgumentException("Can not find a deserializer for non-concrete Collection type " + localCollectionType2); localObject = localClass; } Constructor localConstructor = ClassUtil.findConstructor((Class)localObject, paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)); if (localJavaType.getRawClass() == String.class) return new StringCollectionDeserializer(localCollectionType2, localJsonDeserializer2, localConstructor); return (JsonDeserializer<?>)new CollectionDeserializer(localCollectionType2, localJsonDeserializer2, localTypeDeserializer, localConstructor); }
public Object deserializeFromString(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException, JsonProcessingException { if (this._stringCreator != null) return this._stringCreator.construct(paramJsonParser.getText()); if (this._delegatingCreator != null) return this._delegatingCreator.deserialize(paramJsonParser, paramDeserializationContext); if ((paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) && (paramJsonParser.getTextLength() == 0)) return null; throw paramDeserializationContext.instantiationException(getBeanClass(), "no suitable creator method found to deserialize from JSON String"); }
public void wrapAndThrow(Throwable paramThrowable, Object paramObject, int paramInt, DeserializationContext paramDeserializationContext) throws IOException { while (((paramThrowable instanceof InvocationTargetException)) && (paramThrowable.getCause() != null)) paramThrowable = paramThrowable.getCause(); if ((paramThrowable instanceof Error)) throw ((Error)paramThrowable); int i; if ((paramDeserializationContext == null) || (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.WRAP_EXCEPTIONS))) i = 1; while (true) if ((paramThrowable instanceof IOException)) { if ((i != 0) && ((paramThrowable instanceof JsonMappingException))) break; throw ((IOException)paramThrowable); i = 0; continue; } else { if ((i != 0) || (!(paramThrowable instanceof RuntimeException))) break; throw ((RuntimeException)paramThrowable); } throw JsonMappingException.wrapWithPath(paramThrowable, paramObject, paramInt); }
public void wrapAndThrow(Throwable paramThrowable, Object paramObject, String paramString, DeserializationContext paramDeserializationContext) throws IOException { while (((paramThrowable instanceof InvocationTargetException)) && (paramThrowable.getCause() != null)) paramThrowable = paramThrowable.getCause(); if ((paramThrowable instanceof Error)) throw ((Error)paramThrowable); int i; if ((paramDeserializationContext == null) || (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.WRAP_EXCEPTIONS))) i = 1; while (true) if ((paramThrowable instanceof IOException)) { if ((i != 0) && ((paramThrowable instanceof JsonMappingException))) break; throw ((IOException)paramThrowable); i = 0; continue; } else { if ((i != 0) || (!(paramThrowable instanceof RuntimeException))) break; throw ((RuntimeException)paramThrowable); } throw JsonMappingException.wrapWithPath(paramThrowable, paramObject, paramString); }
protected void wrapInstantiationProblem(Throwable paramThrowable, DeserializationContext paramDeserializationContext) throws IOException { while (((paramThrowable instanceof InvocationTargetException)) && (paramThrowable.getCause() != null)) paramThrowable = paramThrowable.getCause(); if ((paramThrowable instanceof Error)) throw ((Error)paramThrowable); if ((paramDeserializationContext == null) || (paramDeserializationContext.isEnabled(DeserializationConfig.Feature.WRAP_EXCEPTIONS))); for (int i = 1; (paramThrowable instanceof IOException); i = 0) throw ((IOException)paramThrowable); if ((i == 0) && ((paramThrowable instanceof RuntimeException))) throw ((RuntimeException)paramThrowable); throw paramDeserializationContext.instantiationException(this._beanType.getRawClass(), paramThrowable); }
private final Object[] handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException, JsonProcessingException { if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { if ((paramJsonParser.getCurrentToken() == JsonToken.VALUE_STRING) && (this._elementClass == Byte.class)) return deserializeFromBase64(paramJsonParser, paramDeserializationContext); throw paramDeserializationContext.mappingException(this._arrayType.getRawClass()); } Object localObject; if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL) { localObject = null; if (!this._untyped) break label118; } label118: for (Object[] arrayOfObject = new Object[1]; ; arrayOfObject = (Object[])(Object[])Array.newInstance(this._elementClass, 1)) { arrayOfObject[0] = localObject; return arrayOfObject; if (this._elementTypeDeserializer == null) { localObject = this._elementDeserializer.deserialize(paramJsonParser, paramDeserializationContext); break; } localObject = this._elementDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, this._elementTypeDeserializer); break; } }