aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2018-11-19 20:23:23 +0000
committerGerrit Code Review <gerrit@onap.org>2018-11-19 20:23:23 +0000
commita282dc819d213d556da4f04f48bef24d832869d4 (patch)
tree9bb9e26654d14f6d149cb02904a782e974e07b69
parentcbf28e8929492b03d654196fd5e422845fba3e46 (diff)
parent02e91b74f1181fe892cfec32fe16b47221640be7 (diff)
Merge "fixed restapicall JsonParser to handle :" into casablanca
-rw-r--r--restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java
index 4a1dfef5..189ddde3 100644
--- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java
+++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java
@@ -55,12 +55,17 @@ public final class JsonParser {
Iterator<String> ii = json.keys();
while (ii.hasNext()) {
String key1 = ii.next();
- wm.put(key1, json.get(key1));
+ String[] subKey = key1.split(":");
+ if (subKey.length == 2) {
+ wm.put(subKey[1], json.get(key1));
+ } else {
+ wm.put(key1, json.get(key1));
+ }
}
Map<String, String> mm = new HashMap<>();
- while (!wm.isEmpty())
+ while (!wm.isEmpty()) {
for (String key : new ArrayList<>(wm.keySet())) {
Object o = wm.get(key);
wm.remove(key);
@@ -74,7 +79,12 @@ public final class JsonParser {
Iterator<String> i = jo.keys();
while (i.hasNext()) {
String key1 = i.next();
- wm.put(key + "." + key1, jo.get(key1));
+ String[] subKey = key1.split(":");
+ if (subKey.length == 2) {
+ wm.put(key + "." + subKey[1], jo.get(key1));
+ } else {
+ wm.put(key + "." + key1, jo.get(key1));
+ }
}
} else if (o instanceof JSONArray) {
JSONArray ja = (JSONArray) o;
@@ -82,10 +92,12 @@ public final class JsonParser {
log.info("Added property: {}_length: {}", key, String.valueOf(ja.length()));
- for (int i = 0; i < ja.length(); i++)
+ for (int i = 0; i < ja.length(); i++) {
wm.put(key + '[' + i + ']', ja.get(i));
+ }
}
}
+ }
return mm;
} catch (JSONException e) {
throw new SvcLogicException("Unable to convert JSON to properties" + e.getLocalizedMessage(), e);