File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ type t = {
7
7
8
8
let decode = json => {
9
9
open JSON
10
+ let optionToNull = opt =>
11
+ switch opt {
12
+ | Some (String (v )) => Null .Value (v )
13
+ | _ => Null
14
+ }
10
15
switch json {
11
16
| Object (dict {
12
17
"title" : String (title ),
@@ -16,18 +21,9 @@ let decode = json => {
16
21
}) =>
17
22
Some ({
18
23
title ,
19
- metaTitle : switch metaTitle {
20
- | Some (String (v )) => Null .Value (v )
21
- | _ => Null .Null
22
- },
23
- description : switch description {
24
- | Some (String (v )) => Null .Value (v )
25
- | _ => Null .Null
26
- },
27
- canonical : switch canonical {
28
- | Some (String (v )) => Null .Value (v )
29
- | _ => Null .Null
30
- },
24
+ metaTitle : metaTitle -> optionToNull ,
25
+ description : description -> optionToNull ,
26
+ canonical : canonical -> optionToNull ,
31
27
})
32
28
| _ => None
33
29
}
You can’t perform that action at this time.
0 commit comments