Map Serialization using JSON
===

I am trying to send an object, which contains Map. 

Here is my client side: 

    public void sendProject(String projectName,ProjectWrapper projectWrapper){
	    try {	
		Client client = Client.create();
		WebResource webResource = client
				.resource(serverAddress + "project/all/" + projectName);
		
		ClientResponse response = webResource.type("application/json")
				.post(ClientResponse.class, projectWrapper);

		if (response.getStatus() != 201) {
			throw new RuntimeException("Failed : HTTP error code : "
					+ response.getStatus());
		}

		String output = response.getEntity(String.class);
		System.out.println(output);

	} catch (Exception e) {
		e.printStackTrace();

	}
}


My server side: 

    	@POST
	@Path("/all/{projectname}")
	@Consumes(MediaType.APPLICATION_JSON)
	public Response sendProject(ProjectWrapper projectWrapper,@PathParam("projectname") String projectname){
		List<Session> sessions = managment.getSessions();	
		projectWrapper.print();
		
		for (Session session : sessions){
			if (session.getProjectName().equals(projectname)){
				session.setPw(projectWrapper);
			}
		}
		
		return Response.status(201).entity("Project has been send successfuly").build();
	}


Class ProjectWrapper: 


    package enceladus.server.objects;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import javax.xml.bind.annotation.XmlRootElement;
    
    import enceladus.client.easy.FileListing;
    
    @XmlRootElement
    public class ProjectWrapper {
    
    	/*
    	 * Tragiczny gwalt Nazwa pliku jakos sciezka wzgledna od kropy Zawartosc
    	 * pliku jako string
    	 */
    
    	private Map<String, String> all = new HashMap<String, String>();
    
    	public ProjectWrapper(){}
    	
    	public Map<String, String> getAll() {
    		return all;
    	}
    	
    	public void setAll(Map<String, String> all) {
    		this.all = all;
    	}
    
    	public void saveAll() {
    
    		for (String fileName : all.keySet()) {
    
    			try {
    
    				File file = new File(fileName);
    
    				file.getParentFile().mkdirs();
    				FileWriter writer = new FileWriter(fileName);
    
    				writer.write(all.get(fileName));
    
    				writer.close();
    
    			} catch (IOException e) {
    				e.printStackTrace();
    			}
    		}
    
    	}
    
    	public void load() {
    
    		FileListing fl = new FileListing();
    		try {
    			List<File> list = fl.getFileListing(new File("./src")); // TODO
    			for (File f : list) {
    				String fileString = "";
    				// czytanie pliku
    				if (f.isFile()) { // zapisujemy tylko pliki
    					FileReader fr = new FileReader(f.toString());
    					BufferedReader br = new BufferedReader(fr);
    					String s;
    
    					while ((s = br.readLine()) != null) {
    						fileString += s + "\n";
    						// System.out.println(s);
    					}
    					fr.close();
    
    					all.put(f.getPath(), fileString);
    				}
    			}
    		} catch (FileNotFoundException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    
    	public void print() { // do testow
    		for (String s : all.keySet()) {
    			System.out.println(s);
    			System.out.println(all.get(s));
    		}
    	}
    
    }


When i am trying to send it by REST i have an Exception: 

> 31-lug-2012 13.45.58 com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
GRAVE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token
 at [Source: org.apache.catalina.connector.CoyoteInputStream@14a616; line: 1, column: 9] (through reference chain: enceladus.server.objects.ProjectWrapper["all"])
	at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
	at org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:219)
	at org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:44)
	at org.codehaus.jackson.map.deser.std.StringDeserializer.deserialize(StringDeserializer.java:13)
	at org.codehaus.jackson.map.deser.std.MapDeserializer._readAndBind(MapDeserializer.java:319)
	at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:249)
	at org.codehaus.jackson.map.deser.std.MapDeserializer.deserialize(MapDeserializer.java:33)
	at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
	at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
	at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
	at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
	at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2695)
	at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1308)
	at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
	at com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy.readFrom(JacksonProviderProxy.java:139)
	at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:474)
	at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(EntityParamDispatchProvider.java:123)
	at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java:46)
	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$EntityParamInInvoker.getParams(AbstractResourceMethodDispatchProvider.java:153)
	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:203)
	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1483)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1414)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)


I am sending other objects in my aplication, some of them contains lists but this is the first time when i am sending class, which contains map. 

Thank in advance 
