### Question:
JsonUtil { private static Map<String, byte[]> toXAttrMap(final Object[] objects) throws IOException { if (objects == null) { return null; } else if (objects.length == 0) { return Maps.newHashMap(); } else { final Map<String, byte[]> xAttrs = Maps.newHashMap(); for(int i = 0; i < objects.length; i++) { Map<?, ?> m = (Map<?, ?>) objects[i]; String name = (String) m.get("name"); String value = (String) m.get("value"); xAttrs.put(name, decodeXAttrValue(value)); } return xAttrs; } }  static String toJsonString(final Token<? extends TokenIdentifier> token
      ); static Token<? extends TokenIdentifier> toToken(
      final Map<?, ?> m); @SuppressWarnings("unchecked") static Token<DelegationTokenIdentifier> toDelegationToken(
      final Map<?, ?> json); static String toJsonString(final Token<? extends TokenIdentifier>[] tokens
      ); static List<Token<?>> toTokenList(final Map<?, ?> json); static String toJsonString(final Exception e); static RemoteException toRemoteException(final Map<?, ?> json); static String toJsonString(final String key, final Object value); static String toJsonString(final HdfsFileStatus status,
      boolean includeType); static HdfsFileStatus toFileStatus(final Map<?, ?> json, boolean includesType); static String toJsonString(final LocatedBlocks locatedblocks
      ); static LocatedBlocks toLocatedBlocks(final Map<?, ?> json
      ); static String toJsonString(final ContentSummary contentsummary); static ContentSummary toContentSummary(final Map<?, ?> json); static String toJsonString(final MD5MD5CRC32FileChecksum checksum); static MD5MD5CRC32FileChecksum toMD5MD5CRC32FileChecksum(
      final Map<?, ?> json); static String toJsonString(final AclStatus status); static AclStatus toAclStatus(final Map<?, ?> json); static String toJsonString(final List<XAttr> xAttrs, 
      final XAttrCodec encoding); static String toJsonString(final List<XAttr> xAttrs); static byte[] getXAttr(final Map<?, ?> json, final String name); static Map<String, byte[]> toXAttrs(final Map<?, ?> json); static List<String> toXAttrNames(final Map<?, ?> json);  }### Answer:
@Test public void testToXAttrMap() throws IOException { String jsonString = "{\"XAttrs\":[{\"name\":\"user.a1\",\"value\":\"0x313233\"}," + "{\"name\":\"user.a2\",\"value\":\"0x313131\"}]}"; Map<?, ?> json = (Map<?, ?>)JSON.parse(jsonString); XAttr xAttr1 = (new XAttr.Builder()).setNameSpace(XAttr.NameSpace.USER). setName("a1").setValue(XAttrCodec.decodeValue("0x313233")).build(); XAttr xAttr2 = (new XAttr.Builder()).setNameSpace(XAttr.NameSpace.USER). setName("a2").setValue(XAttrCodec.decodeValue("0x313131")).build(); List<XAttr> xAttrs = Lists.newArrayList(); xAttrs.add(xAttr1); xAttrs.add(xAttr2); Map<String, byte[]> xAttrMap = XAttrHelper.buildXAttrMap(xAttrs); Map<String, byte[]> parsedXAttrMap = JsonUtil.toXAttrs(json); Assert.assertEquals(xAttrMap.size(), parsedXAttrMap.size()); Iterator<Entry<String, byte[]>> iter = xAttrMap.entrySet().iterator(); while(iter.hasNext()) { Entry<String, byte[]> entry = iter.next(); Assert.assertArrayEquals(entry.getValue(), parsedXAttrMap.get(entry.getKey())); } }