Given a record type and a list of records:
type note = {
text: string,
id: string
};
let notes: list complete_note = [{text: "lol", id: "1"}, {text: "lol2", id: "2"}]
How do I encode this to JSON using bs-json
module?
What I tried: I tried to manually create JSON string using string interpolation in bucklescript, but that's definitely not something I want to do :)
notes
|> Array.of_list
|> Array.map (
fun x => {
// What should I do?
}
)
|> Json.Encode.stringArray
|> Js.Json.stringify;