Krug.JsonUtil (Krug v0.1.0) 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

Link to this function

encodeToLog(map, substitutionsArray \\ [])

View Source

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.encodeToLog(map)
"echo: ping"
iex > map = %{name: "Johannes Backend", age: 57, address: "404 street", prefer_band: "Guns Roses"}
iex > Krug.JsonUtil.encodeToLog(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 > substitutionsArray = [["prefer_band","Prefered Musical Band"],["name","Name"],["age","Age"],
                            ["address","Actual Address"]]
iex > Krug.JsonUtil.encodeToLog(map,substitutionsArray)
"Prefered Musical Band: Guns Roses, Name: Johannes Backend, Age: 57, Actual Address: 404 street"