Code example for JSONObject

Methods: getString

0
		ObjectMapper mapper = new ObjectMapper();
		String s = mapper.writeValueAsString(holder);
		 
		System.out.println("Config Holder JSON:" + s);
				 
		JSONObject obj = new JSONObject(s);
		String type = obj.getString("partitionType");
		String configStr = obj.getString("filterConfig");
		 
		KeyFilterConfigHolder configHolder = new KeyFilterConfigHolder();
        configHolder.setPartitionType(PartitionType.valueOf(type));
        KeyFilterConfig conf = null;
		if (PartitionType.MOD == configHolder.getPartitionType())
		{ 
		   conf = mapper.readValue(configStr,KeyModFilterConfig.class);
		} else if (PartitionType.RANGE == configHolder.getPartitionType()) {
		   conf = mapper.readValue(configStr,KeyRangeFilterConfig.class); 
		} 
		configHolder.setFilterConfig(conf);
		 
		System.out.println("Holder2 is :" + configHolder.toString());