JsonUtil { public static byte[] getXAttr(final Map<?, ?> json, final String name) throws IOException { if (json == null) { return null; } Map<String, byte[]> xAttrs = toXAttrs(json); if (xAttrs != null) { return xAttrs.get(name); } return null; }  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 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);  }
@Test public void testGetXAttrFromJson() throws IOException { String jsonString = "{\"XAttrs\":[{\"name\":\"user.a1\",\"value\":\"0x313233\"}," + "{\"name\":\"user.a2\",\"value\":\"0x313131\"}]}"; ObjectReader reader = new ObjectMapper().reader(Map.class); Map<?, ?> json = reader.readValue(jsonString); byte[] value = JsonUtil.getXAttr(json, "user.a2"); Assert.assertArrayEquals(XAttrCodec.decodeValue("0x313131"), value); }