February 2019
Beginner to intermediate
180 pages
4h 4m
English
Let's now add the functionality to create and update customers. To do this, we'll need to convert our Reason data structure to JSON. In the interface file, DataPureReason.rei, we'll expose a toJson function:
/* DataPureReason.rei */let parse: string => array(CustomerType.t);let toJson: array(CustomerType.t) => string;
And then we'll implement it:
/* DataPureReason.re */let customerToJson = (customer: CustomerType.t) => { let id = customer.id; let name = customer.name; let street = customer.address.street; let city = customer.address.city; let state = customer.address.state; let zip = customer.address.zip; let phone = customer.phone; let email = customer.email; {j| { "id": $id, "name": "$name", "address": { "street": ...Read now
Unlock full access