I am new to akka-http. I am using this in my project. I am not able to understand what exactly marshalling
and unmarshalling
is.
If someone can explain it with a brief example showing how to marshall and unmarshall json.
I am new to akka-http. I am using this in my project. I am not able to understand what exactly marshalling
and unmarshalling
is.
If someone can explain it with a brief example showing how to marshall and unmarshall json.
When you receive a request the in http it is in wire format i.e byte string, Unmarshaling is converting this byte string to higher level format, on the flip side is marshaling were you convert to low level format.
Example in akka-http of converting json
string(str)
to caseclass(person)
:But a better approach is using the entity directive from akka-http:
The example from the documentation here by the way you need the implicit formater in your scope for unmarshaling to succeed and the number to match the number of field in your case class.