Decoding Multi Level Json

Jason.encode(%{
  topic: "dummy",
  msg: Jason.encode(%{a: "message blob"})
})

# or

~s'{"topic":"dummy","msg":#{Jason.encode(Jason.encode(%{a: "message blob"}))}}'

These variants should both work. I’m not sure about exact quoting here, so it might be, that you need to wrap the interpolated value in another pair of quotes.

I prefer the first approach for readability.

1 Like