Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Vector<String> objRecursive(Vector<String> jsonObj, Vector<String> sortie, Vector<String> racine) {
- Vector<String> returnObj = new Vector<>();
- returnObj.addElement("{}");
- Vector<String> returnRacine = racine;
- int isEmpty = 0;
- for(int z = 0; z<jsonObj.size() ; z++)
- {
- JSONObject jsonObject = new JSONObject(jsonObj.elementAt(z));
- System.out.println(racine);
- JSONArray test;
- Vector<String> keys=new Vector<>();
- for (String name : jsonObject.keySet()) {
- keys.addElement(name);
- }
- String pathRacine = racine.get(z);
- if(keys.size() == 0) {
- isEmpty++;
- }
- for(int i = 0; i<keys.size() ; i++) {
- if(jsonObject.get(keys.elementAt(i).toString()) instanceof String)
- {
- pathRacine += keys.elementAt(i).toString() + "/";
- sortie.addElement(pathRacine + jsonObject.get(keys.elementAt(i).toString()) + "(string)");
- //TODO
- }
- else if(jsonObject.get(keys.elementAt(i).toString()) instanceof Integer) {
- pathRacine += keys.elementAt(i).toString() + "/";
- sortie.addElement(pathRacine + jsonObject.get(keys.elementAt(i).toString()) + "(int)");
- //TODO
- }
- else if(jsonObject.get(keys.elementAt(i).toString()) instanceof Boolean) {
- pathRacine += keys.elementAt(i).toString() + "/";
- sortie.addElement(pathRacine + jsonObject.get(keys.elementAt(i).toString()) + "(bool)");
- //TODO
- }
- else if(jsonObject.get(keys.elementAt(i).toString()) instanceof Double) {
- pathRacine += keys.elementAt(i).toString() + "/";
- sortie.addElement(pathRacine + jsonObject.get(keys.elementAt(i).toString()) + "(double)");
- //TODO
- }
- else if(jsonObject.get(keys.elementAt(i).toString()) instanceof JSONArray) {
- test = (JSONArray)jsonObject.get(keys.elementAt(i).toString());
- pathRacine += keys.elementAt(i).toString() + "/";
- for(int y = 0; y<test.length() ; y++) {
- sortie.addElement(pathRacine + test.get(y) + "(array)");
- }
- }
- else if(jsonObject.get(keys.elementAt(i).toString()) instanceof JSONObject) {
- returnObj.addElement(jsonObject.get(keys.elementAt(i).toString()).toString());
- returnRacine.addElement(pathRacine + keys.elementAt(i).toString());
- }
- }
- }
- if(isEmpty == jsonObj.size()) {
- return sortie;
- }
- return objRecursive(returnObj, sortie, returnRacine);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement