CodeforSouth/fbi-api

Standarize json output keys format

Closed this issue · 4 comments

/businesses uses underscores _, inspections uses camelCase, counties don't use any (countyname)

ugh Open Source :(

@marcoslhc this sounds interesting huh? ^ :/

We can use

(defn transform-keys
  "Recursively transforms all map keys in coll with the transform-key fn."
  [transform-key coll]
  (letfn [(transform [x] (if (map? x)
                           (into {} (map (fn [[k v]] [(transform-key k) v]) x))
                           x))]
    (walk/postwalk transform coll)))

and a transform-key function that uses regex to replace some_thing to whatever we agree to for all endpoints, or, we can just use underscore for these keys- removing the transformation we use for inspections into camelCase... and leaving as it was in database.

LOL. I guess we should keep a standars page in the wiki and start refactoring

We'll use underscores for now. Just merged a PR for this. This is what the db/model uses and is simpler. We can reopen if we want to reformat all to camelCase.