aboutsummaryrefslogtreecommitdiffstats
path: root/src/chameleon/txform.clj
diff options
context:
space:
mode:
authorAdrian Batos-Parac <adrian.batos-parac@amdocs.com>2018-02-22 14:43:42 -0500
committerAdrian Batos-Parac <adrian.batos-parac@amdocs.com>2018-02-22 14:46:57 -0500
commite023325d3e76a71ac795ebbdb74f5a89756040a7 (patch)
tree63b2816a829c785f3c0329c3ea57ebd3c4f2937d /src/chameleon/txform.clj
parent2610df2fc29a9d16bb869f652d4d21caeae4c154 (diff)
Initial Commit of Chameleon
Commit the initial set of code for the Chameleon offering to ONAP Change-Id: Ia58bd49eafc0a3702c17c9cab34d666ed1627ba5 Issue-ID: AAI-797 Signed-off-by: Adrian Batos-Parac <adrian.batos-parac@amdocs.com>
Diffstat (limited to 'src/chameleon/txform.clj')
-rw-r--r--src/chameleon/txform.clj19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/chameleon/txform.clj b/src/chameleon/txform.clj
new file mode 100644
index 0000000..95f357f
--- /dev/null
+++ b/src/chameleon/txform.clj
@@ -0,0 +1,19 @@
+(ns chameleon.txform
+ (:require [cheshire.core :refer :all]
+ [clojure.string :as str]))
+
+(defn map-keywords
+ "Maps all string based keys to keywords"
+ [kmap]
+ (into {} (for [[key value] kmap] [(keyword key) value])))
+
+(defn flatten-key
+ "Maps a parent-child pair to a period separated keyword"
+ [parent child]
+ (keyword (str (name parent) "." (name child))))
+
+(defn flatten-entry
+ "Flattens a nested map entry to a period separated keyword entry"
+ [map key]
+ (reduce #(assoc %1 (flatten-key key (first %2)) (second %2))
+ {} (seq (key map))))