Java code List Map, HashMap, JSON parser snippet

 package com.newegg.ec.solr.eventsalestoreservice.tuple;

 import kafka.message.MessageAndMetadata;

 public class DispatcherCell_inProgress extends Cell{
public DispatcherCell_inProgress(MessageAndMetadata<byte[], byte[]> mm) {
super(mm);
} /*
static {
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
}
*/ /*
public HashMap<String, Object> getSingleContent() throws IOException {
Map<String, Object> map = getParseMap(this.getCELL_CONTENT());
map.forEach((k,v)->{
if(k.equalsIgnoreCase("EntityOrList")){
try {
currentContentMap = mapper.readValue(String.valueOf(v), HashMap.class);
} catch (IOException e) {
e.printStackTrace();
}
}
});
return currentContentMap;
} public HashMap<String, Object> getParseMap(String value) throws IOException {
HashMap<String, Object> tempMap = mapper.readValue(value, HashMap.class);
return tempMap;
}
*/ /*
// List of Hashmap
public HashMap<String, Object> getSingleContent() throws IOException { final String[] content = {""};
List<HashMap<String, Object>> lists = getParseMap(this.getCELL_CONTENT());
lists.forEach(item-> content[0] = (String) item.get("EntityOrList"));
currentContentMap = mapper.readValue(content[0], HashMap.class); return currentContentMap ;
} public List<HashMap<String, Object>> getParseMap(String value) throws IOException {
List<HashMap<String, Object>> List = mapper.readValue(value, List.class);
return List;
}
*/ /*
public HashMap<String, Object> getSingleContent() throws IOException { final String[] content = {""};
List lists = getParseMap(this.getCELL_CONTENT());
lists.forEach(item-> content[0] = (String) item.get("EntityOrList"));
currentContentMap = mapper.readValue(content[0], HashMap.class); return currentContentMap ;
} list of list
public List<List<String>> getParseMap(String value) throws IOException {
List<List<String>> List = mapper.readValue(value, List.class);
return List;
}
*/ /*
TransactionNumber
StoreType
StoreID
ItemNumber
Description
ItemType
Priority
Status
Reserved1
StoreIDvice
CountryCode
CompanyCode
IsCombo
ActiveDate
ExpirationDate
*/ // Map of Map
// @Test
// public void getParseMap() throws IOException {
// Map<String, Map<String, Object>> currentContentMap = cell.getParseMap(cell.getCELL_CONTENT());
// currentContentMap.forEach((k,v)->System.out.println("key : " + k + " value : " + v));
// } // List of Map
// @Test
// public void getParseMap() throws IOException {
// String msgBody = cell.getCELL_CONTENT();
// List<HashMap<String, Object>> list = cell.getParseMap(msgBody);
// list.forEach(item->log.info(item.get("Action")));
// list.forEach(item->log.info(item.get("TransactionNumber")));
// } }
上一篇:RHEL7 -- RPM包命名规则


下一篇:Win7下判断当前进程是否以管理员身份运行