Package br.com.caelum.vraptor.serialization

Examples of br.com.caelum.vraptor.serialization.Deserializee


    Gson gson = builder.create();
   
    final Parameter[] parameterNames = paramNameProvider.parametersFor(method.getMethod());
    final Object[] values = new Object[parameterNames.length];
    final Deserializee deserializee = deserializeeInstance.get();

    try {
      String content = getContentOfStream(inputStream);
      logger.debug("json retrieved: {}", content);
     
      if (!isNullOrEmpty(content)) {
        JsonParser parser = new JsonParser();
        JsonElement jsonElement = parser.parse(content);
        if (jsonElement.isJsonObject()) {
          JsonObject root = jsonElement.getAsJsonObject();
   
          deserializee.setWithoutRoot(isWithoutRoot(parameterNames, root));
         
          for(Class<? extends DeserializerConfig> option: method.getMethod().getAnnotation(Consumes.class).options()) {
            DeserializerConfig config = container.instanceFor(option);
            config.config(deserializee);
          }
         
          for (int i = 0; i < types.length; i++) {
            Parameter parameter = parameterNames[i];
            JsonElement node = root.get(parameter.getName());
           
            if (deserializee.isWithoutRoot()) {
              values[i] = gson.fromJson(root, parameter.getParameterizedType());
              logger.info("json without root deserialized");
              break;

            } else if (node != null) {
View Full Code Here


        Integer.class, Dog.class));
    listDog = new DefaultControllerMethod(controllerClass, DogController.class.getDeclaredMethod("list", List.class));
    dogParameterWithoutRoot = new DefaultControllerMethod(controllerClass, DogController.class.getDeclaredMethod("dogParameterWithoutRoot", Dog.class));
    dogParameterNameEqualsJsonPropertyWithoutRoot = new DefaultControllerMethod(controllerClass, DogController.class.getDeclaredMethod("dogParameterNameEqualsJsonPropertyWithoutRoot", Dog.class));
   
    when(deserializeeInstance.get()).thenReturn(new Deserializee());
    when(container.instanceFor(WithRoot.class)).thenReturn(new WithRoot());
    when(container.instanceFor(WithoutRoot.class)).thenReturn(new WithoutRoot());
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.serialization.Deserializee

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.