Krug.JsonUtil (Krug v2.0.27) View Source
Utilitary module to make objects (maps) can be transformated.
Link to this section Summary
Functions
Transform a Map relative to a CRUD object into a string format to be logged/stored in table log on database, in format text similar a json string.
Link to this section Functions
Transform a Map relative to a CRUD object into a string format to be logged/stored in table log on database, in format text similar a json string.
Examples
iex > map = %{echo: "ping"}
iex > Krug.JsonUtil.encode_to_log(map)
"echo: ping"
iex > map = %{name: "Johannes Backend", age: 57, address: "404 street", prefer_band: "Guns Roses"}
iex > Krug.JsonUtil.encode_to_log(map)
"prefer_band: Guns Roses, name: Johannes Backend, age: 57, address: 404 street"
iex > map = %{name: "Johannes Backend", age: 57, address: "404 street", prefer_band: "Guns Roses"}
iex > substitutions_array = [["prefer_band","Prefered Musical Band"],["name","Name"],["age","Age"],
["address","Actual Address"]]
iex > Krug.JsonUtil.encode_to_log(map,substitutions_array)
"Prefered Musical Band: Guns Roses, Name: Johannes Backend, Age: 57, Actual Address: 404 street"