Code example for StringWriter

Methods: toString

0
	 
	private String mapToJsonStr(Map<String,Object> map) throws JsonGenerationException, JsonMappingException, IOException
	{ 
 
		ObjectMapper mapper = new ObjectMapper();
		StringWriter writer = new StringWriter();
		mapper.writeValue(writer, map);
		String str =  writer.toString();
		return str;
	} 
	 
	@Test 
	public void testPhysicalSourceConfigSerialize() throws JsonParseException, JsonMappingException, IOException  
	{ 
		PhysicalSourceConfig pconfig = new PhysicalSourceConfig();
		LogicalSourceConfig tab1 = new LogicalSourceConfig();
		LogicalSourceConfig tab2 = new LogicalSourceConfig();
		LogicalSourceConfig tab3 = new LogicalSourceConfig();
		tab1.setId((short) 1); tab2.setId((short) 2); tab3.setId((short) 3);
 
		ArrayList<LogicalSourceConfig> newSources = new ArrayList<LogicalSourceConfig>();