I have the following data structure:
"properties": {
"P6": "head of government",
"P7": "brother",
"P9": "sister",
"P10": "video",
"P14": "highway marker",
"P15": "road map",
"P16": "highway system",
"P17": "country",
"P18": "image",
"P19": "place of birth",
"P20": "place of death",
"P21": "sex or gender",
...
I'd like to read this in from a file and use it to populate a hashmap of type Map<String,String>
.
I tried to do this using gson but was unsuccessful, I feel there must be a simpler way.
Maybe I should read it in and split it up using the pattern matcher or regex?
This was the code I had been using:
/*
* P values file
*/
String jsonTxt_P = null;
File P_Value_file = new File("properties-es.json");
//raed in the P values
if (P_Value_file.exists())
{
InputStream is = new FileInputStream("properties-es.json");
jsonTxt_P = IOUtils.toString(is);
}
//
Gson json_P = new Gson();
Map<String,String> massive_P_storage_map = new HashMap<String,String>();
massive_P_storage_map = (Map<String,String>) json_P.fromJson(jsonTxt_P, massive_Q_storage_map.getClass());
System.out.println(massive_P_storage_map);