Hi,
Lets say i have defined a struct and StructType method for unmarshaling from json string as follows:
mutable struct Request
from::String
message::String
requesttime::String
end
# Outer Constructor function for creating a request object
Request(from, message) = Request(from, message, string(now()))
# Empty Constructor function for parsing json string
Request() = Request("", "", string(now()))
StructTypes.StructType(:: Type{Request}) = StructTypes.Mutable()
Now I have a json string and I can unmarshall that in to instance of type Response as follows:
test_json = """{"from": "Saru", "message": "Saru to Discovery, Over!"}"""
JSON3.read(test_json, Request)
To do opposite lets say I have a instance of type Request:
test_instance = Request("Saru", "Saru to Discovery, Over!")
The documentation says that I need to create my own implementations such as:
StructTypes.StructType(::Type{Request}) = JSON3.RawType()
JSON3.rawbytes(x::Request) = ...
Can some one help how should I define the marshaling part.