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()) +
|
||||
* ".json")); wr.print(text); wr.close();
|
||||
*/
|
||||
|
||||
System.out.println("AAAAAAAAAAA text " + text);
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
|
@ -314,38 +313,37 @@ public class SarcStats {
|
|||
ConnectDB.getConnection().close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void renameKeysRecursively(String delimiter, JSONArray givenJsonObj) throws Exception {
|
||||
for (Object jjval : givenJsonObj) {
|
||||
if (jjval instanceof JSONArray)
|
||||
renameKeysRecursively(delimiter, (JSONArray) jjval);
|
||||
else if (jjval instanceof JSONObject)
|
||||
renameKeysRecursively(delimiter, (JSONObject) jjval);
|
||||
for(Object jjval : givenJsonObj) {
|
||||
if(jjval instanceof JSONArray)
|
||||
renameKeysRecursively(delimiter, (JSONArray)jjval);
|
||||
else if(jjval instanceof JSONObject)
|
||||
renameKeysRecursively(delimiter, (JSONObject)jjval);
|
||||
// All other types of vals
|
||||
else
|
||||
;
|
||||
else;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void renameKeysRecursively(String delimiter, JSONObject givenJsonObj) throws Exception {
|
||||
Set<String> jkeys = new HashSet<String>(givenJsonObj.keySet());
|
||||
for (String jkey : jkeys) {
|
||||
System.out.println("++++> " + jkey);
|
||||
|
||||
|
||||
String[] splitArray = jkey.split(delimiter);
|
||||
String newJkey = splitArray[splitArray.length - 1];
|
||||
System.out.println("New jkey: " + jkey);
|
||||
|
||||
|
||||
Object jval = givenJsonObj.get(jkey);
|
||||
System.out.println("jval ===> " + jval.getClass().getName());
|
||||
givenJsonObj.remove(jkey);
|
||||
givenJsonObj.put(newJkey, jval);
|
||||
|
||||
if (jval instanceof JSONObject)
|
||||
renameKeysRecursively(delimiter, (JSONObject) jval);
|
||||
|
||||
if (jval instanceof JSONArray) {
|
||||
renameKeysRecursively(delimiter, (JSONArray) jval);
|
||||
|
||||
if(jval instanceof JSONObject)
|
||||
renameKeysRecursively(delimiter, (JSONObject)jval);
|
||||
|
||||
if(jval instanceof JSONArray) {
|
||||
renameKeysRecursively(delimiter, (JSONArray)jval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue