February 2019
Beginner to intermediate
180 pages
4h 4m
English
Let's assume that we've validated the following JSON (it's an array of objects):
[ { "id": 1, "name": "Christina Langworth", "address": { "street": "81 Casey Stravenue", "city": "Beattyview", "state": "TX", "zip": "57918" }, "phone": "877-549-1362", "email": "Christina.Langworth@gmail.com" }, { "id": 2, "name": "Victor Tillman", "address": { "street": "2811 Toby Gardens", "city": "West Enrique", "state": "NV", "zip": "40465" }, "phone": "(502) 091-2292", "email": "Victor.Tillman30@gmail.com" }]
Now that we have validated the JSON, we're ready to classify it:
switch (Js.Json.classify(validated)) {| Js.Json.JSONArray(array) => Belt.Array.map(array, customer => ...)| _ => failwith("Expected an array")};
We pattern-match ...
Read now
Unlock full access