forked from D-Net/dnet-hadoop
Merge branch 'usage-stats-export-wf' of code-repo.d4science.org:spyros/dnet-hadoop into usage-stats-export-wf
This commit is contained in:
commit
17f2748eb4
|
@ -192,7 +192,6 @@ public class SarcStats {
|
||||||
* PrintWriter wr = new PrintWriter(new FileWriter("logs/" + simpleDateFormat.format(start.getTime()) +
|
* PrintWriter wr = new PrintWriter(new FileWriter("logs/" + simpleDateFormat.format(start.getTime()) +
|
||||||
* ".json")); wr.print(text); wr.close();
|
* ".json")); wr.print(text); wr.close();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
System.out.println("AAAAAAAAAAA text " + text);
|
System.out.println("AAAAAAAAAAA text " + text);
|
||||||
|
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
|
@ -314,38 +313,37 @@ public class SarcStats {
|
||||||
ConnectDB.getConnection().close();
|
ConnectDB.getConnection().close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renameKeysRecursively(String delimiter, JSONArray givenJsonObj) throws Exception {
|
private void renameKeysRecursively(String delimiter, JSONArray givenJsonObj) throws Exception {
|
||||||
for (Object jjval : givenJsonObj) {
|
for(Object jjval : givenJsonObj) {
|
||||||
if (jjval instanceof JSONArray)
|
if(jjval instanceof JSONArray)
|
||||||
renameKeysRecursively(delimiter, (JSONArray) jjval);
|
renameKeysRecursively(delimiter, (JSONArray)jjval);
|
||||||
else if (jjval instanceof JSONObject)
|
else if(jjval instanceof JSONObject)
|
||||||
renameKeysRecursively(delimiter, (JSONObject) jjval);
|
renameKeysRecursively(delimiter, (JSONObject)jjval);
|
||||||
// All other types of vals
|
// All other types of vals
|
||||||
else
|
else;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renameKeysRecursively(String delimiter, JSONObject givenJsonObj) throws Exception {
|
private void renameKeysRecursively(String delimiter, JSONObject givenJsonObj) throws Exception {
|
||||||
Set<String> jkeys = new HashSet<String>(givenJsonObj.keySet());
|
Set<String> jkeys = new HashSet<String>(givenJsonObj.keySet());
|
||||||
for (String jkey : jkeys) {
|
for (String jkey : jkeys) {
|
||||||
System.out.println("++++> " + jkey);
|
System.out.println("++++> " + jkey);
|
||||||
|
|
||||||
String[] splitArray = jkey.split(delimiter);
|
String[] splitArray = jkey.split(delimiter);
|
||||||
String newJkey = splitArray[splitArray.length - 1];
|
String newJkey = splitArray[splitArray.length - 1];
|
||||||
System.out.println("New jkey: " + jkey);
|
System.out.println("New jkey: " + jkey);
|
||||||
|
|
||||||
Object jval = givenJsonObj.get(jkey);
|
Object jval = givenJsonObj.get(jkey);
|
||||||
System.out.println("jval ===> " + jval.getClass().getName());
|
System.out.println("jval ===> " + jval.getClass().getName());
|
||||||
givenJsonObj.remove(jkey);
|
givenJsonObj.remove(jkey);
|
||||||
givenJsonObj.put(newJkey, jval);
|
givenJsonObj.put(newJkey, jval);
|
||||||
|
|
||||||
if (jval instanceof JSONObject)
|
if(jval instanceof JSONObject)
|
||||||
renameKeysRecursively(delimiter, (JSONObject) jval);
|
renameKeysRecursively(delimiter, (JSONObject)jval);
|
||||||
|
|
||||||
if (jval instanceof JSONArray) {
|
if(jval instanceof JSONArray) {
|
||||||
renameKeysRecursively(delimiter, (JSONArray) jval);
|
renameKeysRecursively(delimiter, (JSONArray)jval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue