Login or Register


 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Jackson: deserialization of Map
09-19-2012, 12:05 PM
Post: #1
I'm using Jackson to deserialize a json file (that I serialized with jackson). The json is a simple HashMap, but the mapper is complaining when I try and deserialize.\[code\]org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.HashMap out of START_ARRAY token\[/code\]My serialized HashMap string.....\[code\]{"0f861a9a-0a3e-40a7-8ff3-0b83d8070876" : {"name" : "BAR.xml","filePath" : "/FOO/repo/BAR.xml"},"f3cbb32e-b7b8-4af1-b48b-7ea393de7971" : {"name" : "BLAH.xml","filePath" : "/FOO/repo/BLAH.xml"},"012009b6-26e9-4bc1-9050-2a4ac9546c7e" : {"name" : "Check System.xml","filePath" : "/FOO/repo/Check System.xml"}}\[/code\]I've tried 2 different ways to make this work, and both fail...\[code\]//doesn't work cache = (Map<String,UUIDInfo>) mapper.readValue(bytes.toString(), new TypeReference<HashMap<String,UUIDInfo>>(){});//doesn't work.cache = (Map<String,UUIDInfo>) mapper.readValue(bytes.toString(), TypeFactory.mapType(HashMap.class, String.class, UUIDInfo.class));\[/code\]The full stacktrace\[code\]org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token at [Source: java.io.StringReader@32b9bd47; line: 1, column: 1] at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163​) at org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDes​erializationContext.java:198) at org.codehaus.jackson.map.deser.MapDeserializer.deserialize(MapDeserializer.java:​151) at org.codehaus.jackson.map.deser.MapDeserializer.deserialize(MapDeserializer.java:​25) at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2395) at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1602) at com.hp.oo.studio.shared.UUIDRegistry.UUIDRegistry.<init>(UUIDRegistry.java:63) at com.hp.oo.studio.shared.UUIDRegistry.UUIDRegistry.<clinit>(UUIDRegistry.java:37) at com.hp.oo.studio.shared.StudioShared.loadUUIDRegistry(StudioShared.java:93) at com.hp.oo.studio.shared.StudioShared.start(StudioShared.java:42) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextIm​pl.java:711) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(Bundle​ContextImpl.java:702) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextIm​pl.java:683) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:​381) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.jav​a:299) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440) at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:2​68) at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(​EclipseLazyStarter.java:107) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathMan​ager.java:462) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultC​lassLoader.java:216) at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:4​00) at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePacka​ge.java:35) at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.jav​a:473) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassL​oader.java:107) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at com.hp.oo.studio.StudioUI.registerFile(StudioUI.java:133) at com.hp.oo.studio.StudioUI.findFilesInDirectory(StudioUI.java:125) at com.hp.oo.studio.StudioUI.findFilesInDirectory(StudioUI.java:120) at com.hp.oo.studio.StudioUI.start(StudioUI.java:75) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextIm​pl.java:711) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(Bundle​ContextImpl.java:702) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextIm​pl.java:683) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:​381) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.jav​a:299) at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:440) at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(BundleLoader.java:2​68) at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(​EclipseLazyStarter.java:107) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathMan​ager.java:462) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultC​lassLoader.java:216) at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:4​00) at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.jav​a:476) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassL​oader.java:107) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:345) at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:22​9) at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle​.java:1207) at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExt​ension(RegistryStrategyOSGI.java:174) at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(E​xtensionRegistry.java:905) at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtensio​n(ConfigurationElement.java:243) at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableEx​tension(ConfigurationElementHandle.java:55) at org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:268) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:264​) at org.eclipse.ui.internal.registry.EditorDescriptor.createEditor(EditorDescriptor.​java:235) at org.eclipse.ui.internal.EditorManager.createPart(EditorManager.java:875) at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:60​9) at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465) at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.ja​va:595) at org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(EditorAreaHelper.java:​271) at org.eclipse.ui.internal.EditorManager.setVisibleEditor(EditorManager.java:1459) at org.eclipse.ui.internal.EditorManager$5.runWithException(EditorManager.java:972)​ at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.ja​va:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:80​3) at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:1595) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.ja​va:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java​:123) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)​ at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Ecli​pseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLau​ncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav​a:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386)\[/code\]
Reply


Forum Jump:


User(s) browsing this thread: 1 Guest(s)