Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper.readValue()


        mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);

        T result = null;
        try {
            if(o instanceof InputStream)
                result = mapper.readValue((InputStream) o, clazz);
            if(o instanceof String)
                result = mapper.readValue((String) o, clazz);
        } catch (IOException e) {
            // pass
        }
View Full Code Here


        T result = null;
        try {
            if(o instanceof InputStream)
                result = mapper.readValue((InputStream) o, clazz);
            if(o instanceof String)
                result = mapper.readValue((String) o, clazz);
        } catch (IOException e) {
            // pass
        }

        return result;
View Full Code Here

      boolean json_error = false;
      try {
        // read JSON
        ObjectMapper mapper = new ObjectMapper();
        Map<String, String> nm =
          mapper.readValue(new File(localFileName), Map.class);

        for(Map.Entry<String, String> ent: nm.entrySet()) {
          credentials.addSecretKey(new Text(ent.getKey()),
                                   ent.getValue().getBytes());
        }
View Full Code Here

            return;

        ObjectMapper m = new ObjectMapper();
        try
        {
            JsonNode rootNode = m.readValue(manifestFile, JsonNode.class);
            JsonNode generations = rootNode.get("generations");
            assert generations.isArray();
            for (JsonNode generation : generations)
            {
                int level = generation.get("generation").getIntValue();
View Full Code Here

    JSONObject response = webResource.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).post(JSONObject.class, formData);
    System.out.println("answer: "+response.toString());
        ObjectMapper mapper = new ObjectMapper();
        List<AcoustIdWsResult> results = null;
        try {
      results  = mapper.readValue(response.getString("results"), new TypeReference<List<AcoustIdWsResult>>(){});
    } catch (JsonParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (JsonMappingException e) {
      // TODO Auto-generated catch block
View Full Code Here

                response = c.resource(SERVICE_URL).accept("application/json").header("X-Scanner", 1).post(JSONObject.class, request);
            } else {
                response = c.resource(SERVICE_URL).accept("application/json").post(JSONObject.class, request);
            }
            ObjectMapper mapper = new ObjectMapper();
            trackList = mapper.readValue(response.getString("result"), TrackListData.class);

            if (trackList != null) {
                while (trackList != null && !isAborted()) {
                    long i = 0;
                    entityManager.getTransaction().begin();
View Full Code Here

                        if (squeezeboxServerPasswordHash != null && squeezeboxServerPasswordHash.length() > 0) {
                            response = c.resource(SERVICE_URL).accept("application/json").header("X-Scanner", 1).post(JSONObject.class, request);
                        } else {
                            response = c.resource(SERVICE_URL).accept("application/json").post(JSONObject.class, request);
                        }
                        trackList = mapper.readValue(response.getString("result"), TrackListData.class);
                    } else {
                        trackList = null;
                    }
                }
View Full Code Here

            int noOfTracks = 0;
            for (String playlistUri : playlistUris) {
                response = c.resource(SERVICE_URL + "/" + playlistUri + "/playlists.json").accept("application/json").get(JSONObject.class);

                try {
                    SpotifyPlaylistData playlistData = mapper.readValue(response.toString(), SpotifyPlaylistData.class);
                    playlists.add(playlistData);
                    noOfTracks += playlistData.getTracks().size();
                } catch (JsonMappingException e) {
                    e.printStackTrace();
                    //TODO: Error handling ?
View Full Code Here

      JsonMappingException,
      IOException
  {
    StringReader sr = new StringReader(jsonString);
    ObjectMapper mapper = new ObjectMapper();
    return mapper.readValue(sr, clazz);

  }

  public static Map<String, String> JsonToMap(String jsonString) throws JsonParseException,
      JsonMappingException,
View Full Code Here

    TypeReference<TreeMap<String, String>> typeRef =
        new TypeReference<TreeMap<String, String>>()
        {
        };

    return mapper.readValue(sr, typeRef);
  }

  public static Map<String, String> getFormJsonParameters(Form form) throws JsonParseException,
      JsonMappingException,
      IOException
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.