├── src ├── jsonCodec_function.re ├── jsonCodec_xor.re ├── jsonCodec_result.re ├── jsonCodec_core.re ├── jsonCodec_util.re ├── jsonCodec.re └── jsonCodec_object.re ├── .gitignore ├── bsconfig.json ├── package.json ├── tasks.json ├── README.md ├── scripts └── generate.js ├── LICENSE.txt └── __tests__ └── jsonCodecTest.re /src/jsonCodec_function.re: -------------------------------------------------------------------------------- 1 | let const = (x, _) => x; 2 | 3 | module Ops = { 4 | let (>>>) = (f, g, x) => g(f(x)); 5 | }; 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.obj 3 | *.out 4 | *.compile 5 | *.native 6 | *.byte 7 | *.cmo 8 | *.annot 9 | *.cmi 10 | *.cmx 11 | *.cmt 12 | *.cmti 13 | *.cma 14 | *.a 15 | *.cmxa 16 | *.obj 17 | *~ 18 | *.annot 19 | *.cmj 20 | *.bak 21 | lib/ 22 | node_modules/ 23 | *.mlast 24 | *.mliast 25 | .vscode 26 | .merlin -------------------------------------------------------------------------------- /bsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-codec", 3 | "version": "0.1.0", 4 | "bsc-flags": ["-bs-super-errors"], 5 | "sources": [ 6 | "src", 7 | { 8 | "dir": "__tests__", 9 | "type": "dev" 10 | } 11 | ], 12 | "refmt": 3, 13 | "bs-dev-dependencies": [ 14 | "@glennsl/bs-jest", 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /src/jsonCodec_xor.re: -------------------------------------------------------------------------------- 1 | module Function = JsonCodec_function; 2 | 3 | type t('a, 'b) = 4 | | Left('a) 5 | | Right('b); 6 | 7 | let left = a : t('a, 'b) => Left(a); 8 | 9 | let right = b : t('a, 'b) => Right(b); 10 | 11 | let either = (f, g, xor) => 12 | switch (xor) { 13 | | Left(x) => f(x) 14 | | Right(y) => g(y) 15 | }; 16 | 17 | let toOption = x => either(Function.const(None), Js.Option.some) @@ x; 18 | 19 | let fromOption = 20 | fun 21 | | Some(x) => right(x) 22 | | None => left(); 23 | -------------------------------------------------------------------------------- /src/jsonCodec_result.re: -------------------------------------------------------------------------------- 1 | include Belt.Result; 2 | 3 | let fromOption = (o: option('a), error: 'b) : t('a, 'b) => 4 | switch (o) { 5 | | Some(x) => Ok(x) 6 | | None => Error(error) 7 | }; 8 | 9 | let map = (f: 'a => 'b, result: t('a, 'c)) : t('b, 'c) => 10 | switch (result) { 11 | | Ok(x) => Ok(f(x)) 12 | | Error(y) => Error(y) 13 | }; 14 | 15 | module Ops = { 16 | let (>>=) = (result: t('a, 'c), f: 'a => t('b, 'c)) : t('b, 'c) => 17 | switch (result) { 18 | | Ok(x) => f(x) 19 | | Error(y) => Error(y) 20 | }; 21 | }; 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-codec", 3 | "version": "0.1.0", 4 | "description": "JSON combinator library for BuckleScript/Reason", 5 | "scripts": { 6 | "clean": "bsb -clean-world", 7 | "generate": "node scripts/generate.js && bsrefmt --in-place src/jsonCodec_object.re", 8 | "build": "npm run generate && bsb -make-world", 9 | "watch": "bsb -make-world -w", 10 | "test": "npm run build && jest", 11 | "format": "bsrefmt --in-place src/*.re" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/state-machine-systems/JsonCodec.git" 16 | }, 17 | "homepage": "https://github.com/state-machine-systems/JsonCodec#readme", 18 | "bugs": "https://github.com/state-machine-systems/JsonCodec/issues", 19 | "keywords": [ 20 | "JSON", 21 | "BuckleScript", 22 | "Reason" 23 | ], 24 | "license": "Apache-2.0", 25 | "devDependencies": { 26 | "@glennsl/bs-jest": "0.4.2", 27 | "bs-platform": "3.1.5", 28 | "jest-cli": "^23.1.0" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "npm", 4 | "options": { 5 | "cwd": "${workspaceRoot}" 6 | }, 7 | "isShellCommand": true, 8 | "args": [ 9 | "run", 10 | "watch" 11 | ], 12 | "showOutput": "always", 13 | "isBackground": true, 14 | "problemMatcher": { 15 | "fileLocation": "absolute", 16 | "owner": "ocaml", 17 | "watching": { 18 | "activeOnStart": false, 19 | "beginsPattern": ">>>> Start compiling", 20 | "endsPattern": ">>>> Finish compiling" 21 | }, 22 | "pattern": [ 23 | { 24 | "regexp": "^File \"(.*)\", line (\\d+)(?:, characters (\\d+)-(\\d+))?:$", 25 | "file": 1, 26 | "line": 2, 27 | "column": 3, 28 | "endColumn": 4 29 | }, 30 | { 31 | "regexp": "^(?:(?:Parse\\s+)?(Warning|[Ee]rror)(?:\\s+\\d+)?:)?\\s+(.*)$", 32 | "severity": 1, 33 | "message": 2, 34 | "loop": true 35 | } 36 | ] 37 | } 38 | } -------------------------------------------------------------------------------- /src/jsonCodec_core.re: -------------------------------------------------------------------------------- 1 | module Result = JsonCodec_result; 2 | 3 | module Util = JsonCodec_util; 4 | 5 | open Result.Ops; 6 | 7 | module Encoder = { 8 | type t('a, 'b) = 'a => 'b; 9 | }; 10 | 11 | module Decoder = { 12 | type error = string; 13 | type result('a) = Result.t('a, error); 14 | type t('a, 'b) = 'b => result('a); 15 | }; 16 | 17 | module JsonEncoder = { 18 | type t('a) = Encoder.t('a, Js.Json.t); 19 | }; 20 | 21 | module JsonDecoder = { 22 | type t('a) = Decoder.t('a, Js.Json.t); 23 | }; 24 | 25 | module Codec = { 26 | type t('a) = (JsonEncoder.t('a), JsonDecoder.t('a)); 27 | }; 28 | 29 | module GenericCodec = { 30 | type t('a, 'b, 'c) = (Encoder.t('a, 'b), Decoder.t('a, 'c)); 31 | }; 32 | 33 | module FieldEncoder = { 34 | type t('a) = Encoder.t('a, option((Js.Dict.key, Js.Json.t))); 35 | }; 36 | 37 | module FieldDecoder = { 38 | type dict = Js.Dict.t(Js.Json.t); 39 | type t('a) = Decoder.t('a, dict); 40 | }; 41 | 42 | module FieldCodec = { 43 | type t('a) = (FieldEncoder.t('a), FieldDecoder.t('a)); 44 | }; 45 | 46 | let encode = ((enc, _): Codec.t('a), x) => enc(x); 47 | 48 | let decode = ((_, dec): Codec.t('a), x) => dec(x); 49 | 50 | let encodeJson = (~spaces=2, codec, a) => 51 | Util.formatJson(encode(codec, a), spaces); 52 | 53 | let decodeJson = (codec, s) => Util.parseJson(s) >>= decode(codec); 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JsonCodec 2 | 3 | ## JSON combinator library for BuckleScript/Reason 4 | 5 | Using the magic of [pickler combinators](https://www.microsoft.com/en-us/research/wp-content/uploads/2004/01/picklercombinators.pdf), this library allows you to parse and serialize JSON structures in a declarative way, free of boilerplate. 6 | 7 | Here's a little example: 8 | 9 | ```reason 10 | let json = {js| 11 | { 12 | "name": "Great Pyramid of Giza", 13 | "lat": 29.979175, 14 | "lon": 31.134358, 15 | "height": 146.5 16 | } 17 | |js}; 18 | 19 | /* Define a codec for the above object type */ 20 | let codec = 21 | JsonCodec.( 22 | object4( 23 | field("name", string), 24 | field("lat", number), 25 | field("lon", number), 26 | field("height", number), 27 | ) 28 | ); 29 | 30 | /* Decoding */ 31 | switch (JsonCodec.decodeJson(codec, json)) { 32 | | Belt.Result.Ok((name, lat, lon, height)) => 33 | Printf.printf("name='%s' location=%f,%f height=%f\n", name, lat, lon, height) 34 | | Belt.Result.Error(error) => Printf.printf("Decoding error: %s", error) 35 | }; 36 | 37 | /* Encoding */ 38 | let encoded = 39 | JsonCodec.encodeJson(codec, ("Machu Picchu", -13.163333, -72.545556, 2430.0)); 40 | 41 | Printf.printf("JSON: %s\n", encoded); 42 | ``` 43 | 44 | 45 | © 2017-2018 State Machine Systems Ltd. [Apache Licence, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) 46 | -------------------------------------------------------------------------------- /scripts/generate.js: -------------------------------------------------------------------------------- 1 | let fs = require('fs'); 2 | 3 | let contents = [ 4 | "/* This file is auto-generated. Please do not modify it. */", 5 | "open JsonCodec_result.Ops;" 6 | ]; 7 | for (let i = 1; i <= 26; i++) { 8 | contents.push(generateObjectCodec(i)); 9 | } 10 | 11 | fs.writeFile("src/jsonCodec_object.re", contents.join("\n"), function(err) { 12 | if (err) { 13 | console.log(err); 14 | process.exit(1); 15 | } 16 | }); 17 | 18 | function generateObjectCodec(n) { 19 | let letters = " abcdefghijklmnopqrstuvwxyz"; 20 | let numbers = [...Array(n).keys()].map(k => k + 1); 21 | let typeVariable = i => `'${letters[i]}`; 22 | 23 | // start of declaration 24 | let code = [`let object${n} = (`]; 25 | 26 | // arguments 27 | numbers.forEach(i => code.push( 28 | `(enc${i}, dec${i}): JsonCodec_core.FieldCodec.t(${typeVariable(i)}),`)); 29 | 30 | // return type 31 | code.push("): JsonCodec_core.Codec.t(("); 32 | code.push(numbers.map(typeVariable).join(", ")); 33 | code.push("))"); 34 | 35 | // body start 36 | code.push("=> {"); 37 | 38 | // encoder declaration 39 | code.push("let encode = (("); 40 | code.push(numbers.map(i => `v${i}`).join(", ")); 41 | code.push(")) => Js.Json.object_ @@ JsonCodec_util.buildDict(["); 42 | code.push(numbers.map(i => `enc${i}(v${i})`).join(", ")); 43 | code.push("]);"); 44 | 45 | // decoder declaration 46 | code.push("let decode = json => JsonCodec_util.decodeRawObject(json) >>="); 47 | code.push(`dict => dec1(dict)`); 48 | for (let i = 1; i < n; i++) { 49 | code.push(`>>= v${i} => dec${i + 1}(dict)`); 50 | } 51 | if (n > 1) { 52 | code.push(`>>= v${n} => Belt.Result.Ok((`); 53 | code.push(numbers.map(i => `v${i}`).join(", ")); 54 | code.push("))"); 55 | } 56 | code.push(";"); 57 | 58 | // return value 59 | code.push("(encode, decode)"); 60 | 61 | // body end 62 | code.push("};"); 63 | 64 | return code.join(" "); 65 | } 66 | -------------------------------------------------------------------------------- /src/jsonCodec_util.re: -------------------------------------------------------------------------------- 1 | module Result = JsonCodec_result; 2 | 3 | open Result.Ops; 4 | 5 | let parseJson = s => 6 | try (Result.Ok(Js.Json.parseExn(s))) { 7 | | Js.Exn.Error(e) => 8 | Result.Error( 9 | Js.Exn.message(e) |> Js.Option.getWithDefault("JSON parsing failed"), 10 | ) 11 | }; 12 | 13 | [@bs.val] [@bs.scope "JSON"] 14 | external formatJson : (Js.Json.t, [@bs.as {json|null|json}] _, int) => string = 15 | "stringify"; 16 | 17 | let decodeArrayElements = (decode, elements) => { 18 | let length = Js.Array.length(elements); 19 | let output = [||]; 20 | let rec loop = i => 21 | if (i == length) { 22 | Result.Ok(output); 23 | } else { 24 | switch (decode(elements[i])) { 25 | | Result.Ok(decoded) => 26 | ignore(Js.Array.push(decoded, output)); 27 | loop(i + 1); 28 | | Result.Error(error) => Result.Error(error) 29 | }; 30 | }; 31 | loop(0); 32 | }; 33 | 34 | let decoderOf = (f, error, x) => Result.fromOption(f(x), error); 35 | 36 | let decodeRawObject = decoderOf(Js.Json.decodeObject, "Expected object"); 37 | 38 | let decodeRawArray = decoderOf(Js.Json.decodeArray, "Expected array"); 39 | 40 | let decodeRawNumber = decoderOf(Js.Json.decodeNumber, "Expected number"); 41 | 42 | let decodeRawBool = decoderOf(Js.Json.decodeBoolean, "Expected boolean"); 43 | 44 | let decodeRawString = decoderOf(Js.Json.decodeString, "Expected string"); 45 | 46 | let decodeRawNull = decoderOf(Js.Json.decodeNull, "Expected null"); 47 | 48 | let validInt = (x: float) => { 49 | let xInt = int_of_float(x); 50 | if (x == float_of_int(xInt)) { 51 | Result.Ok(x); 52 | } else { 53 | Result.Error("Not an int: " ++ string_of_float(x)); 54 | }; 55 | }; 56 | 57 | let decodeMandatoryField = (decode, name, dict) => 58 | Result.fromOption( 59 | Js.Dict.get(dict, name), 60 | "Field '" ++ name ++ "' not found", 61 | ) 62 | >>= decode; 63 | 64 | let decodeOptionalField = (decode, name, dict) => 65 | Result.Ok(Js.Dict.get(dict, name)) 66 | >>= ( 67 | fun 68 | | Some(x) => decode(x) |> Result.map(Js.Option.some) 69 | | None => Result.Ok(None) 70 | ); 71 | 72 | let buildDict = fields => { 73 | let dict = Js.Dict.empty(); 74 | let rec loop = remaining => 75 | switch (remaining) { 76 | | [] => dict 77 | | [Some((name, value)), ...tail] => 78 | Js.Dict.set(dict, name, value); 79 | loop(tail); 80 | | [None, ...tail] => loop(tail) 81 | }; 82 | loop(fields); 83 | }; 84 | -------------------------------------------------------------------------------- /src/jsonCodec.re: -------------------------------------------------------------------------------- 1 | module Option = Js.Option; 2 | 3 | module Json = Js.Json; 4 | 5 | module Dict = Js.Dict; 6 | 7 | include JsonCodec_core; 8 | 9 | include JsonCodec_object; 10 | 11 | module Function = JsonCodec_function; 12 | 13 | open Function.Ops; 14 | 15 | module Xor = JsonCodec_xor; 16 | 17 | open Result.Ops; 18 | 19 | let wrap = 20 | (f: 'b => 'a, g: 'a => 'b, (enc, dec): GenericCodec.t('a, 'c, 'd)) 21 | : GenericCodec.t('b, 'c, 'd) => ( 22 | f >>> enc, 23 | dec >>> Result.map(g), 24 | ); 25 | 26 | let validate = 27 | (f: 'a => Decoder.result('a), (enc, dec): GenericCodec.t('a, 'c, 'd)) 28 | : GenericCodec.t('b, 'c, 'd) => ( 29 | enc, 30 | x => dec(x) >>= f, 31 | ); 32 | 33 | let constant = 34 | ((enc, dec): GenericCodec.t('a, 'c, 'd), value: 'a) 35 | : GenericCodec.t('a, 'c, 'd) => { 36 | let checkValue = 37 | fun 38 | | v when v == value => Result.Ok(v) 39 | | _ => 40 | Result.Error( 41 | "Expected constant value " 42 | ++ encodeJson(~spaces=0, (enc, dec), value), 43 | ); 44 | validate(checkValue, (Function.const(enc(value)), dec)); 45 | }; 46 | 47 | let number: Codec.t(float) = (Json.number, Util.decodeRawNumber); 48 | 49 | let int: Codec.t(int) = 50 | number |> validate(Util.validInt) |> wrap(float_of_int, int_of_float); 51 | 52 | let bool: Codec.t(bool) = (Json.boolean, Util.decodeRawBool); 53 | 54 | let string: Codec.t(string) = (Json.string, Util.decodeRawString); 55 | 56 | let null: Codec.t(unit) = ( 57 | Function.const(Json.null), 58 | Util.decodeRawNull >>> Result.map(Function.const()), 59 | ); 60 | 61 | let xor = 62 | ((enc1, dec1): Codec.t('a), (enc2, dec2): Codec.t('b)) 63 | : Codec.t(Xor.t('a, 'b)) => ( 64 | Xor.either(enc1, enc2), 65 | x => 66 | switch (dec1(x)) { 67 | | Result.Ok(y) => Result.Ok(Xor.left(y)) 68 | | Result.Error(_) => Result.map(Xor.right, dec2(x)) 69 | }, 70 | ); 71 | 72 | let nullable = (codec: Codec.t('a)) : Codec.t(option('a)) => 73 | xor(null, codec) |> wrap(Xor.fromOption, Xor.toOption); 74 | 75 | let array = ((enc, dec): Codec.t('a)) : Codec.t(Js.Array.t('a)) => { 76 | let encode = value => Json.array(Js.Array.map(enc, value)); 77 | let decode = json => 78 | Util.decodeRawArray(json) >>= Util.decodeArrayElements(dec); 79 | (encode, decode); 80 | }; 81 | 82 | let list = (codec: Codec.t('a)) : Codec.t(list('a)) => 83 | wrap(Array.of_list, Array.to_list, array(codec)); 84 | 85 | let dict = ((enc, dec): Codec.t('a)) : Codec.t(Dict.t('a)) => { 86 | let encode = dict => Json.object_(Dict.map((. x) => enc(x), dict)); 87 | let decode = json => 88 | Util.decodeRawObject(json) 89 | >>= ( 90 | obj => { 91 | let keys = Dict.keys(obj); 92 | let length = Array.length(keys); 93 | let dict = Dict.empty(); 94 | let rec loop = i => 95 | if (i < length) { 96 | let k = keys[i]; 97 | dec(Dict.unsafeGet(obj, k)) 98 | >>= ( 99 | decoded => { 100 | Dict.set(dict, k, decoded); 101 | loop(i + 1); 102 | } 103 | ); 104 | } else { 105 | Result.Ok(dict); 106 | }; 107 | loop(0); 108 | } 109 | ); 110 | (encode, decode); 111 | }; 112 | 113 | let fix = (f: Codec.t('a) => Codec.t('a)) : Codec.t('a) => { 114 | let encoderRef: ref(option(JsonEncoder.t('a))) = ref(None); 115 | let decoderRef: ref(option(JsonDecoder.t('a))) = ref(None); 116 | let emptyCodec: Codec.t('a) = ( 117 | value => Option.getExn(encoderRef^) @@ value, 118 | json => Option.getExn(decoderRef^) @@ json, 119 | ); 120 | let (encode, decode) = f(emptyCodec); 121 | encoderRef := Some(encode); 122 | decoderRef := Some(decode); 123 | (encode, decode); 124 | }; 125 | 126 | let field = (name: Dict.key, (enc, dec): Codec.t('a)) : FieldCodec.t('a) => ( 127 | value => Some((name, enc(value))), 128 | Util.decodeMandatoryField(dec, name), 129 | ); 130 | 131 | let optional = 132 | (name: Dict.key, (enc, dec): Codec.t('a)) 133 | : FieldCodec.t(option('a)) => ( 134 | Option.map((. value) => (name, enc(value))), 135 | Util.decodeOptionalField(dec, name), 136 | ); 137 | 138 | let optionalNullable = 139 | (name: Dict.key, codec: Codec.t('a)) 140 | : FieldCodec.t(option('a)) => { 141 | let flatten = 142 | fun 143 | | Some(Some(x)) => Some(x) 144 | | Some(None) 145 | | None => None; 146 | optional(name, nullable(codec)) |> wrap(Option.some, flatten); 147 | }; 148 | 149 | let object0: Codec.t(unit) = ( 150 | Function.const(Json.object_(Dict.empty())), 151 | Util.decodeRawObject >>> Result.map(Function.const()), 152 | ); 153 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /__tests__/jsonCodecTest.re: -------------------------------------------------------------------------------- 1 | open Jest; 2 | 3 | module C = JsonCodec; 4 | module Result = JsonCodec.Result; 5 | 6 | let formatJsonString = s => Js.Json.parseExn(s) |> Js.Json.stringify; 7 | 8 | type tree('a) = 9 | | Leaf('a) 10 | | Branch(tree('a), tree('a)); 11 | 12 | let () = 13 | describe( 14 | "JsonCodec", 15 | ExpectJs.( 16 | () => { 17 | let jsonString = "\"foo\""; 18 | let jsonNumberArray = formatJsonString("[1.1, 2.2]"); 19 | let jsonEmptyObject = "{}"; 20 | let jsonSingleStringFieldObject = 21 | formatJsonString({js|{"foo": "bar"}|js}); 22 | let jsonSingleNumberFieldObject = 23 | formatJsonString({js|{"foo": 12.34}|js}); 24 | let jsonTwoFieldObject = 25 | formatJsonString({js|{"foo": "bar", "baz": true}|js}); 26 | let jsonThreeFieldObject = 27 | formatJsonString({js|{"foo": "bar", "baz": true, "qux": 56.78}|js}); 28 | let jsonFourFieldObject = 29 | formatJsonString( 30 | {js|{"foo": "bar", "baz": true, "qux": 56.78, "quux": null}|js}, 31 | ); 32 | describe("number", () => { 33 | test("encoding", () => 34 | expect(C.encodeJson(C.number, 3.14)) |> toEqual("3.14") 35 | ); 36 | test("decoding success", () => 37 | expect(C.decodeJson(C.number, "3.14")) 38 | |> toEqual(Result.Ok(3.14)) 39 | ); 40 | test("decoding failure, not a number", () => 41 | expect(C.decodeJson(C.number, jsonString)) 42 | |> toEqual(Result.Error("Expected number")) 43 | ); 44 | test("decoding failure, invalid JSON", () => 45 | expect(C.decodeJson(C.number, "_")) 46 | |> toEqual( 47 | Result.Error("Unexpected token _ in JSON at position 0"), 48 | ) 49 | ); 50 | }); 51 | describe("int", () => { 52 | test("encoding", () => 53 | expect(C.encodeJson(C.int, 1)) |> toEqual("1") 54 | ); 55 | test("decoding success, no decimal point", () => 56 | expect(C.decodeJson(C.int, "1")) |> toEqual(Result.Ok(1)) 57 | ); 58 | test("decoding success, zero after decimal point", () => 59 | expect(C.decodeJson(C.int, "1.0")) |> toEqual(Result.Ok(1)) 60 | ); 61 | test("decoding failure, can't represent as int", () => 62 | expect(C.decodeJson(C.int, "1.234")) 63 | |> toEqual(Result.Error("Not an int: 1.234")) 64 | ); 65 | }); 66 | describe("string", () => { 67 | test("encoding", () => 68 | expect(C.encodeJson(C.string, "foo")) |> toEqual(jsonString) 69 | ); 70 | test("decoding success", () => 71 | expect(C.decodeJson(C.string, jsonString)) 72 | |> toEqual(Result.Ok("foo")) 73 | ); 74 | test("decoding failure", () => 75 | expect(C.decodeJson(C.string, "0.5")) 76 | |> toEqual(Result.Error("Expected string")) 77 | ); 78 | }); 79 | describe("bool", () => { 80 | test("encoding", () => 81 | expect(C.encodeJson(C.bool, true)) |> toEqual("true") 82 | ); 83 | test("decoding success", () => 84 | expect(C.decodeJson(C.bool, "false")) 85 | |> toEqual(Result.Ok(false)) 86 | ); 87 | test("decoding failure", () => 88 | expect(C.decodeJson(C.bool, jsonString)) 89 | |> toEqual(Result.Error("Expected boolean")) 90 | ); 91 | }); 92 | describe("null", () => { 93 | test("encoding", () => 94 | expect(C.encodeJson(C.null, ())) |> toEqual("null") 95 | ); 96 | test("decoding success", () => 97 | expect(C.decodeJson(C.null, "null")) |> toEqual(Result.Ok()) 98 | ); 99 | test("decoding failure", () => 100 | expect(C.decodeJson(C.null, "true")) 101 | |> toEqual(Result.Error("Expected null")) 102 | ); 103 | }); 104 | describe("nullable", () => { 105 | test("empty encoding", () => 106 | expect(C.encodeJson(C.nullable(C.string), None)) 107 | |> toEqual("null") 108 | ); 109 | test("empty decoding success", () => 110 | expect(C.decodeJson(C.nullable(C.string), "null")) 111 | |> toEqual(Result.Ok(None)) 112 | ); 113 | test("non-empty encoding", () => 114 | expect(C.encodeJson(C.nullable(C.string), Some("foo"))) 115 | |> toEqual(jsonString) 116 | ); 117 | test("non-empty decoding success", () => 118 | expect(C.decodeJson(C.nullable(C.number), "1.0")) 119 | |> toEqual(Result.Ok(Some(1.0))) 120 | ); 121 | test("decoding failure", () => 122 | expect(C.decodeJson(C.nullable(C.string), "1.0")) 123 | |> toEqual(Result.Error("Expected string")) 124 | ); 125 | }); 126 | describe("array", () => { 127 | test("empty encoding", () => 128 | expect(C.encodeJson(C.array(C.number), [||])) |> toEqual("[]") 129 | ); 130 | test("empty decoding", () => 131 | expect(C.decodeJson(C.array(C.string), "[]")) 132 | |> toEqual(Result.Ok([||])) 133 | ); 134 | test("non-empty encoding", () => 135 | expect( 136 | C.encodeJson(C.array(C.number), [|1.1, 2.2|]) 137 | |> formatJsonString, 138 | ) 139 | |> toEqual(jsonNumberArray) 140 | ); 141 | test("non-empty decoding success", () => 142 | expect(C.decodeJson(C.array(C.number), jsonNumberArray)) 143 | |> toEqual(Result.Ok([|1.1, 2.2|])) 144 | ); 145 | test("decoding failure", () => 146 | expect(C.decodeJson(C.array(C.string), "true")) 147 | |> toEqual(Result.Error("Expected array")) 148 | ); 149 | test("element decoding failure", () => 150 | expect(C.decodeJson(C.array(C.string), jsonNumberArray)) 151 | |> toEqual(Result.Error("Expected string")) 152 | ); 153 | }); 154 | describe("object0", () => { 155 | test("encoding", () => 156 | expect(C.encodeJson(C.object0, ())) |> toEqual("{}") 157 | ); 158 | test("decoding success", () => 159 | expect(C.decodeJson(C.object0, "{}")) |> toEqual(Result.Ok()) 160 | ); 161 | test("decoding success, ignoring extra fields", () => 162 | expect(C.decodeJson(C.object0, jsonSingleStringFieldObject)) 163 | |> toEqual(Result.Ok()) 164 | ); 165 | test("decoding failure", () => 166 | expect(C.decodeJson(C.object0, "null")) 167 | |> toEqual(Result.Error("Expected object")) 168 | ); 169 | }); 170 | describe("object1", () => { 171 | let codec = C.object1(C.field("foo", C.string)); 172 | test("encoding", () => 173 | expect(C.encodeJson(~spaces=0, codec, "bar")) 174 | |> toEqual(jsonSingleStringFieldObject) 175 | ); 176 | test("decoding success", () => 177 | expect(C.decodeJson(codec, jsonSingleStringFieldObject)) 178 | |> toEqual(Result.Ok("bar")) 179 | ); 180 | test("decoding success, ignoring extra fields", () => 181 | expect(C.decodeJson(codec, jsonTwoFieldObject)) 182 | |> toEqual(Result.Ok("bar")) 183 | ); 184 | test("decoding failure, not an object", () => 185 | expect(C.decodeJson(codec, "false")) 186 | |> toEqual(Result.Error("Expected object")) 187 | ); 188 | test("decoding failure, missing field", () => 189 | expect(C.decodeJson(codec, "{}")) 190 | |> toEqual(Result.Error("Field 'foo' not found")) 191 | ); 192 | test("decoding failure, wrong field type", () => 193 | expect(C.decodeJson(codec, jsonSingleNumberFieldObject)) 194 | |> toEqual(Result.Error("Expected string")) 195 | ); 196 | }); 197 | describe("object2", () => { 198 | let codec = 199 | C.object2(C.field("foo", C.string), C.field("baz", C.bool)); 200 | test("encoding", () => 201 | expect(C.encodeJson(~spaces=0, codec, ("bar", true))) 202 | |> toEqual(jsonTwoFieldObject) 203 | ); 204 | test("decoding success", () => 205 | expect(C.decodeJson(codec, jsonTwoFieldObject)) 206 | |> toEqual(Result.Ok(("bar", true))) 207 | ); 208 | test("decoding success, ignoring extra fields", () => 209 | expect(C.decodeJson(codec, jsonThreeFieldObject)) 210 | |> toEqual(Result.Ok(("bar", true))) 211 | ); 212 | test("decoding failure, not an object", () => 213 | expect(C.decodeJson(codec, "7.77")) 214 | |> toEqual(Result.Error("Expected object")) 215 | ); 216 | test("decoding failure, missing field", () => 217 | expect(C.decodeJson(codec, jsonSingleStringFieldObject)) 218 | |> toEqual(Result.Error("Field 'baz' not found")) 219 | ); 220 | test("decoding failure, wrong field type", () => 221 | expect(C.decodeJson(codec, jsonSingleNumberFieldObject)) 222 | |> toEqual(Result.Error("Expected string")) 223 | ); 224 | }); 225 | describe("object3", () => { 226 | let codec = 227 | C.object3( 228 | C.field("foo", C.string), 229 | C.field("baz", C.bool), 230 | C.field("qux", C.number), 231 | ); 232 | test("encoding", () => 233 | expect(C.encodeJson(~spaces=0, codec, ("bar", true, 56.78))) 234 | |> toEqual(jsonThreeFieldObject) 235 | ); 236 | test("decoding success", () => 237 | expect(C.decodeJson(codec, jsonThreeFieldObject)) 238 | |> toEqual(Result.Ok(("bar", true, 56.78))) 239 | ); 240 | test("decoding success, ignoring extra fields", () => 241 | expect(C.decodeJson(codec, jsonFourFieldObject)) 242 | |> toEqual(Result.Ok(("bar", true, 56.78))) 243 | ); 244 | test("decoding failure, not an object", () => 245 | expect(C.decodeJson(codec, "null")) 246 | |> toEqual(Result.Error("Expected object")) 247 | ); 248 | test("decoding failure, missing field", () => 249 | expect(C.decodeJson(codec, jsonTwoFieldObject)) 250 | |> toEqual(Result.Error("Field 'qux' not found")) 251 | ); 252 | test("decoding failure, wrong field type", () => 253 | expect(C.decodeJson(codec, jsonSingleNumberFieldObject)) 254 | |> toEqual(Result.Error("Expected string")) 255 | ); 256 | }); 257 | describe("object4", () => { 258 | let codec = 259 | C.object4( 260 | C.field("foo", C.string), 261 | C.field("baz", C.bool), 262 | C.field("qux", C.number), 263 | C.field("quux", C.null), 264 | ); 265 | test("encoding", () => 266 | expect(C.encodeJson(~spaces=0, codec, ("bar", true, 56.78, ()))) 267 | |> toEqual(jsonFourFieldObject) 268 | ); 269 | test("decoding", () => 270 | expect(C.decodeJson(codec, jsonFourFieldObject)) 271 | |> toEqual(Result.Ok(("bar", true, 56.78, ()))) 272 | ); 273 | }); 274 | describe("object5", () => { 275 | let json = 276 | formatJsonString( 277 | {js|{"f1": 1, "f2": 2, "f3": 3, "f4": 4, "f5": 5}|js}, 278 | ); 279 | let codec = 280 | C.object5( 281 | C.field("f1", C.int), 282 | C.field("f2", C.int), 283 | C.field("f3", C.int), 284 | C.field("f4", C.int), 285 | C.field("f5", C.int), 286 | ); 287 | test("encoding", () => 288 | expect(C.encodeJson(~spaces=0, codec, (1, 2, 3, 4, 5))) 289 | |> toEqual(json) 290 | ); 291 | test("decoding", () => 292 | expect(C.decodeJson(codec, json)) 293 | |> toEqual(Result.Ok((1, 2, 3, 4, 5))) 294 | ); 295 | }); 296 | describe("object6", () => { 297 | let json = 298 | formatJsonString( 299 | {js|{"f1": 1, "f2": 2, "f3": 3, "f4": 4, "f5": 5, "f6": 6}|js}, 300 | ); 301 | let codec = 302 | C.object6( 303 | C.field("f1", C.int), 304 | C.field("f2", C.int), 305 | C.field("f3", C.int), 306 | C.field("f4", C.int), 307 | C.field("f5", C.int), 308 | C.field("f6", C.int), 309 | ); 310 | test("encoding", () => 311 | expect(C.encodeJson(~spaces=0, codec, (1, 2, 3, 4, 5, 6))) 312 | |> toEqual(json) 313 | ); 314 | test("decoding", () => 315 | expect(C.decodeJson(codec, json)) 316 | |> toEqual(Result.Ok((1, 2, 3, 4, 5, 6))) 317 | ); 318 | }); 319 | describe("object7", () => { 320 | let json = 321 | formatJsonString( 322 | {js|{"f1": 1, "f2": 2, "f3": 3, "f4": 4, "f5": 5, "f6": 6, "f7": 7}|js}, 323 | ); 324 | let codec = 325 | C.object7( 326 | C.field("f1", C.int), 327 | C.field("f2", C.int), 328 | C.field("f3", C.int), 329 | C.field("f4", C.int), 330 | C.field("f5", C.int), 331 | C.field("f6", C.int), 332 | C.field("f7", C.int), 333 | ); 334 | test("encoding", () => 335 | expect(C.encodeJson(~spaces=0, codec, (1, 2, 3, 4, 5, 6, 7))) 336 | |> toEqual(json) 337 | ); 338 | test("decoding", () => 339 | expect(C.decodeJson(codec, json)) 340 | |> toEqual(Result.Ok((1, 2, 3, 4, 5, 6, 7))) 341 | ); 342 | }); 343 | describe("object8", () => { 344 | let json = 345 | formatJsonString( 346 | {js|{"f1": 1, "f2": 2, "f3": 3, "f4": 4, "f5": 5, "f6": 6, "f7": 7, "f8": 8}|js}, 347 | ); 348 | let codec = 349 | C.object8( 350 | C.field("f1", C.int), 351 | C.field("f2", C.int), 352 | C.field("f3", C.int), 353 | C.field("f4", C.int), 354 | C.field("f5", C.int), 355 | C.field("f6", C.int), 356 | C.field("f7", C.int), 357 | C.field("f8", C.int), 358 | ); 359 | test("encoding", () => 360 | expect(C.encodeJson(~spaces=0, codec, (1, 2, 3, 4, 5, 6, 7, 8))) 361 | |> toEqual(json) 362 | ); 363 | test("decoding", () => 364 | expect(C.decodeJson(codec, json)) 365 | |> toEqual(Result.Ok((1, 2, 3, 4, 5, 6, 7, 8))) 366 | ); 367 | }); 368 | describe("object9", () => { 369 | let json = 370 | formatJsonString( 371 | {js|{"f1": 1, "f2": 2, "f3": 3, "f4": 4, "f5": 5, "f6": 6, "f7": 7, "f8": 8, "f9": 9}|js}, 372 | ); 373 | let codec = 374 | C.object9( 375 | C.field("f1", C.int), 376 | C.field("f2", C.int), 377 | C.field("f3", C.int), 378 | C.field("f4", C.int), 379 | C.field("f5", C.int), 380 | C.field("f6", C.int), 381 | C.field("f7", C.int), 382 | C.field("f8", C.int), 383 | C.field("f9", C.int), 384 | ); 385 | test("encoding", () => 386 | expect( 387 | C.encodeJson(~spaces=0, codec, (1, 2, 3, 4, 5, 6, 7, 8, 9)), 388 | ) 389 | |> toEqual(json) 390 | ); 391 | test("decoding", () => 392 | expect(C.decodeJson(codec, json)) 393 | |> toEqual(Result.Ok((1, 2, 3, 4, 5, 6, 7, 8, 9))) 394 | ); 395 | }); 396 | describe("object10", () => { 397 | let json = 398 | formatJsonString( 399 | {js|{"f1": 1, "f2": 2, "f3": 3, "f4": 4, "f5": 5, "f6": 6, "f7": 7, "f8": 8, "f9": 9, "f10": 10}|js}, 400 | ); 401 | let codec = 402 | C.object10( 403 | C.field("f1", C.int), 404 | C.field("f2", C.int), 405 | C.field("f3", C.int), 406 | C.field("f4", C.int), 407 | C.field("f5", C.int), 408 | C.field("f6", C.int), 409 | C.field("f7", C.int), 410 | C.field("f8", C.int), 411 | C.field("f9", C.int), 412 | C.field("f10", C.int), 413 | ); 414 | test("encoding", () => 415 | expect( 416 | C.encodeJson( 417 | ~spaces=0, 418 | codec, 419 | (1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 420 | ), 421 | ) 422 | |> toEqual(json) 423 | ); 424 | test("decoding", () => 425 | expect(C.decodeJson(codec, json)) 426 | |> toEqual(Result.Ok((1, 2, 3, 4, 5, 6, 7, 8, 9, 10))) 427 | ); 428 | }); 429 | describe("optional and nullable fields", () => { 430 | let nullableFieldCodec = 431 | C.(object1(field("foo", nullable(string)))); 432 | let optionalFieldCodec = C.(object1(optional("foo", string))); 433 | let optionalNullableFieldCodec = 434 | C.(object1(optional("foo", nullable(string)))); 435 | let flattenedFieldCodec = 436 | C.(object1(C.optionalNullable("foo", string))); 437 | let jsonNullField = formatJsonString("{\"foo\": null}"); 438 | describe("nullable field", () => { 439 | test("empty encoding", () => 440 | expect(C.encodeJson(~spaces=0, nullableFieldCodec, None)) 441 | |> toEqual(jsonNullField) 442 | ); 443 | test("empty decoding", () => 444 | expect(C.decodeJson(nullableFieldCodec, jsonNullField)) 445 | |> toEqual(Result.Ok(None)) 446 | ); 447 | test("non-empty encoding", () => 448 | expect( 449 | C.encodeJson(~spaces=0, nullableFieldCodec, Some("bar")), 450 | ) 451 | |> toEqual(jsonSingleStringFieldObject) 452 | ); 453 | test("non-empty decoding", () => 454 | expect( 455 | C.decodeJson(nullableFieldCodec, jsonSingleStringFieldObject), 456 | ) 457 | |> toEqual(Result.Ok(Some("bar"))) 458 | ); 459 | }); 460 | describe("optional field", () => { 461 | test("empty encoding", () => 462 | expect(C.encodeJson(optionalFieldCodec, None)) 463 | |> toEqual(jsonEmptyObject) 464 | ); 465 | test("empty decoding", () => 466 | expect(C.decodeJson(optionalFieldCodec, jsonEmptyObject)) 467 | |> toEqual(Result.Ok(None)) 468 | ); 469 | test("non-empty encoding", () => 470 | expect( 471 | C.encodeJson(~spaces=0, optionalFieldCodec, Some("bar")), 472 | ) 473 | |> toEqual(jsonSingleStringFieldObject) 474 | ); 475 | test("non-empty decoding success", () => 476 | expect( 477 | C.decodeJson(optionalFieldCodec, jsonSingleStringFieldObject), 478 | ) 479 | |> toEqual(Result.Ok(Some("bar"))) 480 | ); 481 | test("non-empty decoding failure", () => 482 | expect( 483 | C.decodeJson(optionalFieldCodec, jsonSingleNumberFieldObject), 484 | ) 485 | |> toEqual(Result.Error("Expected string")) 486 | ); 487 | }); 488 | describe("optional nullable field", () => { 489 | test("empty encoding", () => 490 | expect(C.encodeJson(optionalNullableFieldCodec, None)) 491 | |> toEqual(jsonEmptyObject) 492 | ); 493 | test("empty decoding", () => 494 | expect( 495 | C.decodeJson(optionalNullableFieldCodec, jsonEmptyObject), 496 | ) 497 | |> toEqual(Result.Ok(None)) 498 | ); 499 | test("null encoding", () => 500 | expect( 501 | C.encodeJson( 502 | ~spaces=0, 503 | optionalNullableFieldCodec, 504 | Some(None), 505 | ), 506 | ) 507 | |> toEqual(jsonNullField) 508 | ); 509 | test("null decoding", () => 510 | expect(C.decodeJson(optionalNullableFieldCodec, jsonNullField)) 511 | |> toEqual(Result.Ok(Some(None))) 512 | ); 513 | test("non-null encoding", () => 514 | expect( 515 | C.encodeJson( 516 | ~spaces=0, 517 | optionalNullableFieldCodec, 518 | Some(Some("bar")), 519 | ), 520 | ) 521 | |> toEqual(jsonSingleStringFieldObject) 522 | ); 523 | test("non-null decoding", () => 524 | expect( 525 | C.decodeJson( 526 | optionalNullableFieldCodec, 527 | jsonSingleStringFieldObject, 528 | ), 529 | ) 530 | |> toEqual(Result.Ok(Some(Some("bar")))) 531 | ); 532 | }); 533 | describe("flattened optional nullable field", () => { 534 | test("empty encoding", () => 535 | expect(C.encodeJson(~spaces=0, flattenedFieldCodec, None)) 536 | |> toEqual(jsonNullField) 537 | ); 538 | test("empty decoding, missing field", () => 539 | expect(C.decodeJson(flattenedFieldCodec, jsonEmptyObject)) 540 | |> toEqual(Result.Ok(None)) 541 | ); 542 | test("empty decoding, null field", () => 543 | expect(C.decodeJson(flattenedFieldCodec, jsonNullField)) 544 | |> toEqual(Result.Ok(None)) 545 | ); 546 | test("non-empty encoding", () => 547 | expect( 548 | C.encodeJson(~spaces=0, flattenedFieldCodec, Some("bar")), 549 | ) 550 | |> toEqual(jsonSingleStringFieldObject) 551 | ); 552 | test("non-empty decoding", () => 553 | expect( 554 | C.decodeJson( 555 | flattenedFieldCodec, 556 | jsonSingleStringFieldObject, 557 | ), 558 | ) 559 | |> toEqual(Result.Ok(Some("bar"))) 560 | ); 561 | }); 562 | }); 563 | describe("recursion", () => { 564 | let intTree = Branch(Branch(Leaf(1), Leaf(2)), Leaf(3)); 565 | let intTreeJson = 566 | formatJsonString( 567 | {js|{"left": {"left": 1, "right": 2}, "right": 3}|js}, 568 | ); 569 | let treeToXor = 570 | fun 571 | | Leaf(x) => C.Xor.left(x) 572 | | Branch(l, r) => C.Xor.right((l, r)); 573 | let xorToTree = 574 | fun 575 | | C.Xor.Left(x) => Leaf(x) 576 | | C.Xor.Right((l, r)) => Branch(l, r); 577 | let codec = 578 | JsonCodec.( 579 | fix(tree => 580 | xor( 581 | int, 582 | object2(field("left", tree), field("right", tree)), 583 | ) 584 | |> wrap(treeToXor, xorToTree) 585 | ) 586 | ); 587 | test("encoding", () => 588 | expect(C.encodeJson(~spaces=0, codec, intTree)) 589 | |> toEqual(intTreeJson) 590 | ); 591 | test("decoding", () => 592 | expect(C.decodeJson(codec, intTreeJson)) 593 | |> toEqual(Result.Ok(intTree)) 594 | ); 595 | }); 596 | describe("constant", () => { 597 | describe("constant string", () => { 598 | let codec = C.constant(C.string, "foo"); 599 | test("encoding", () => 600 | expect(C.encodeJson(codec, "anything")) |> toEqual(jsonString) 601 | ); 602 | test("decoding success", () => 603 | expect(C.decodeJson(codec, jsonString)) 604 | |> toEqual(Result.Ok("foo")) 605 | ); 606 | test("decoding failure, wrong value", () => 607 | expect(C.decodeJson(codec, "\"bar\"")) 608 | |> toEqual(Result.Error("Expected constant value \"foo\"")) 609 | ); 610 | test("decoding failure, wrong type", () => 611 | expect(C.decodeJson(codec, jsonNumberArray)) 612 | |> toEqual(Result.Error("Expected string")) 613 | ); 614 | }); 615 | describe("constant field value", () => { 616 | let fieldCodec = C.field("type", C.constant(C.string, "X")); 617 | let objectCodec = C.object1(fieldCodec); 618 | let expectedJson = {js|{"type":"X"}|js}; 619 | test("encoding", () => 620 | expect(C.encodeJson(~spaces=0, objectCodec, "...")) 621 | |> toEqual(expectedJson) 622 | ); 623 | test("decoding", () => 624 | expect(C.decodeJson(objectCodec, expectedJson)) 625 | |> toEqual(Result.Ok("X")) 626 | ); 627 | }); 628 | }); 629 | describe("dict", () => { 630 | let codec = C.dict(C.int); 631 | let emptyDict = Js.Dict.empty(); 632 | let emptyDictJson = {js|{}|js}; 633 | let nonEmptyDict = Js.Dict.fromArray([|("x", 1), ("y", 2)|]); 634 | let nonEmptyDictJson = {js|{"x":1,"y":2}|js}; 635 | test("empty encoding", () => 636 | expect(C.encodeJson(~spaces=0, codec, emptyDict)) 637 | |> toEqual(emptyDictJson) 638 | ); 639 | test("empty decoding", () => 640 | expect(C.decodeJson(codec, emptyDictJson)) 641 | |> toEqual(Result.Ok(emptyDict)) 642 | ); 643 | test("non-empty encoding", () => 644 | expect(C.encodeJson(~spaces=0, codec, nonEmptyDict)) 645 | |> toEqual(nonEmptyDictJson) 646 | ); 647 | test("non-empty decoding", () => 648 | expect(C.decodeJson(codec, nonEmptyDictJson)) 649 | |> toEqual(Result.Ok(nonEmptyDict)) 650 | ); 651 | }); 652 | describe("list", () => { 653 | let codec = C.list(C.int); 654 | let emptyList = []; 655 | let emptyListJson = {js|[]|js}; 656 | let nonEmptyList = [1, 2, 3]; 657 | let nonEmptyListJson = {js|[1,2,3]|js}; 658 | test("empty encoding", () => 659 | expect(C.encodeJson(~spaces=0, codec, emptyList)) 660 | |> toEqual(emptyListJson) 661 | ); 662 | test("empty decoding", () => 663 | expect(C.decodeJson(codec, emptyListJson)) 664 | |> toEqual(Result.Ok(emptyList)) 665 | ); 666 | test("non-empty encoding", () => 667 | expect(C.encodeJson(~spaces=0, codec, nonEmptyList)) 668 | |> toEqual(nonEmptyListJson) 669 | ); 670 | test("non-empty decoding", () => 671 | expect(C.decodeJson(codec, nonEmptyListJson)) 672 | |> toEqual(Result.Ok(nonEmptyList)) 673 | ); 674 | }); 675 | } 676 | ), 677 | ); 678 | -------------------------------------------------------------------------------- /src/jsonCodec_object.re: -------------------------------------------------------------------------------- 1 | /* This file is auto-generated. Please do not modify it. */ 2 | open JsonCodec_result.Ops; 3 | let object1 = 4 | ((enc1, dec1): JsonCodec_core.FieldCodec.t('a)) 5 | : JsonCodec_core.Codec.t('a) => { 6 | let encode = v1 => Js.Json.object_ @@ JsonCodec_util.buildDict([enc1(v1)]); 7 | let decode = json => 8 | JsonCodec_util.decodeRawObject(json) >>= (dict => dec1(dict)); 9 | (encode, decode); 10 | }; 11 | let object2 = 12 | ( 13 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 14 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 15 | ) 16 | : JsonCodec_core.Codec.t(('a, 'b)) => { 17 | let encode = ((v1, v2)) => 18 | Js.Json.object_ @@ JsonCodec_util.buildDict([enc1(v1), enc2(v2)]); 19 | let decode = json => 20 | JsonCodec_util.decodeRawObject(json) 21 | >>= ( 22 | dict => 23 | dec1(dict) 24 | >>= (v1 => dec2(dict) >>= (v2 => Belt.Result.Ok((v1, v2)))) 25 | ); 26 | (encode, decode); 27 | }; 28 | let object3 = 29 | ( 30 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 31 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 32 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 33 | ) 34 | : JsonCodec_core.Codec.t(('a, 'b, 'c)) => { 35 | let encode = ((v1, v2, v3)) => 36 | Js.Json.object_ @@ 37 | JsonCodec_util.buildDict([enc1(v1), enc2(v2), enc3(v3)]); 38 | let decode = json => 39 | JsonCodec_util.decodeRawObject(json) 40 | >>= ( 41 | dict => 42 | dec1(dict) 43 | >>= ( 44 | v1 => 45 | dec2(dict) 46 | >>= (v2 => dec3(dict) >>= (v3 => Belt.Result.Ok((v1, v2, v3)))) 47 | ) 48 | ); 49 | (encode, decode); 50 | }; 51 | let object4 = 52 | ( 53 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 54 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 55 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 56 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 57 | ) 58 | : JsonCodec_core.Codec.t(('a, 'b, 'c, 'd)) => { 59 | let encode = ((v1, v2, v3, v4)) => 60 | Js.Json.object_ @@ 61 | JsonCodec_util.buildDict([enc1(v1), enc2(v2), enc3(v3), enc4(v4)]); 62 | let decode = json => 63 | JsonCodec_util.decodeRawObject(json) 64 | >>= ( 65 | dict => 66 | dec1(dict) 67 | >>= ( 68 | v1 => 69 | dec2(dict) 70 | >>= ( 71 | v2 => 72 | dec3(dict) 73 | >>= ( 74 | v3 => 75 | dec4(dict) >>= (v4 => Belt.Result.Ok((v1, v2, v3, v4))) 76 | ) 77 | ) 78 | ) 79 | ); 80 | (encode, decode); 81 | }; 82 | let object5 = 83 | ( 84 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 85 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 86 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 87 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 88 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 89 | ) 90 | : JsonCodec_core.Codec.t(('a, 'b, 'c, 'd, 'e)) => { 91 | let encode = ((v1, v2, v3, v4, v5)) => 92 | Js.Json.object_ @@ 93 | JsonCodec_util.buildDict([ 94 | enc1(v1), 95 | enc2(v2), 96 | enc3(v3), 97 | enc4(v4), 98 | enc5(v5), 99 | ]); 100 | let decode = json => 101 | JsonCodec_util.decodeRawObject(json) 102 | >>= ( 103 | dict => 104 | dec1(dict) 105 | >>= ( 106 | v1 => 107 | dec2(dict) 108 | >>= ( 109 | v2 => 110 | dec3(dict) 111 | >>= ( 112 | v3 => 113 | dec4(dict) 114 | >>= ( 115 | v4 => 116 | dec5(dict) 117 | >>= (v5 => Belt.Result.Ok((v1, v2, v3, v4, v5))) 118 | ) 119 | ) 120 | ) 121 | ) 122 | ); 123 | (encode, decode); 124 | }; 125 | let object6 = 126 | ( 127 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 128 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 129 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 130 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 131 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 132 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 133 | ) 134 | : JsonCodec_core.Codec.t(('a, 'b, 'c, 'd, 'e, 'f)) => { 135 | let encode = ((v1, v2, v3, v4, v5, v6)) => 136 | Js.Json.object_ @@ 137 | JsonCodec_util.buildDict([ 138 | enc1(v1), 139 | enc2(v2), 140 | enc3(v3), 141 | enc4(v4), 142 | enc5(v5), 143 | enc6(v6), 144 | ]); 145 | let decode = json => 146 | JsonCodec_util.decodeRawObject(json) 147 | >>= ( 148 | dict => 149 | dec1(dict) 150 | >>= ( 151 | v1 => 152 | dec2(dict) 153 | >>= ( 154 | v2 => 155 | dec3(dict) 156 | >>= ( 157 | v3 => 158 | dec4(dict) 159 | >>= ( 160 | v4 => 161 | dec5(dict) 162 | >>= ( 163 | v5 => 164 | dec6(dict) 165 | >>= ( 166 | v6 => Belt.Result.Ok((v1, v2, v3, v4, v5, v6)) 167 | ) 168 | ) 169 | ) 170 | ) 171 | ) 172 | ) 173 | ); 174 | (encode, decode); 175 | }; 176 | let object7 = 177 | ( 178 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 179 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 180 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 181 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 182 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 183 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 184 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 185 | ) 186 | : JsonCodec_core.Codec.t(('a, 'b, 'c, 'd, 'e, 'f, 'g)) => { 187 | let encode = ((v1, v2, v3, v4, v5, v6, v7)) => 188 | Js.Json.object_ @@ 189 | JsonCodec_util.buildDict([ 190 | enc1(v1), 191 | enc2(v2), 192 | enc3(v3), 193 | enc4(v4), 194 | enc5(v5), 195 | enc6(v6), 196 | enc7(v7), 197 | ]); 198 | let decode = json => 199 | JsonCodec_util.decodeRawObject(json) 200 | >>= ( 201 | dict => 202 | dec1(dict) 203 | >>= ( 204 | v1 => 205 | dec2(dict) 206 | >>= ( 207 | v2 => 208 | dec3(dict) 209 | >>= ( 210 | v3 => 211 | dec4(dict) 212 | >>= ( 213 | v4 => 214 | dec5(dict) 215 | >>= ( 216 | v5 => 217 | dec6(dict) 218 | >>= ( 219 | v6 => 220 | dec7(dict) 221 | >>= ( 222 | v7 => 223 | Belt.Result.Ok(( 224 | v1, 225 | v2, 226 | v3, 227 | v4, 228 | v5, 229 | v6, 230 | v7, 231 | )) 232 | ) 233 | ) 234 | ) 235 | ) 236 | ) 237 | ) 238 | ) 239 | ); 240 | (encode, decode); 241 | }; 242 | let object8 = 243 | ( 244 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 245 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 246 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 247 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 248 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 249 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 250 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 251 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 252 | ) 253 | : JsonCodec_core.Codec.t(('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h)) => { 254 | let encode = ((v1, v2, v3, v4, v5, v6, v7, v8)) => 255 | Js.Json.object_ @@ 256 | JsonCodec_util.buildDict([ 257 | enc1(v1), 258 | enc2(v2), 259 | enc3(v3), 260 | enc4(v4), 261 | enc5(v5), 262 | enc6(v6), 263 | enc7(v7), 264 | enc8(v8), 265 | ]); 266 | let decode = json => 267 | JsonCodec_util.decodeRawObject(json) 268 | >>= ( 269 | dict => 270 | dec1(dict) 271 | >>= ( 272 | v1 => 273 | dec2(dict) 274 | >>= ( 275 | v2 => 276 | dec3(dict) 277 | >>= ( 278 | v3 => 279 | dec4(dict) 280 | >>= ( 281 | v4 => 282 | dec5(dict) 283 | >>= ( 284 | v5 => 285 | dec6(dict) 286 | >>= ( 287 | v6 => 288 | dec7(dict) 289 | >>= ( 290 | v7 => 291 | dec8(dict) 292 | >>= ( 293 | v8 => 294 | Belt.Result.Ok(( 295 | v1, 296 | v2, 297 | v3, 298 | v4, 299 | v5, 300 | v6, 301 | v7, 302 | v8, 303 | )) 304 | ) 305 | ) 306 | ) 307 | ) 308 | ) 309 | ) 310 | ) 311 | ) 312 | ); 313 | (encode, decode); 314 | }; 315 | let object9 = 316 | ( 317 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 318 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 319 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 320 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 321 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 322 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 323 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 324 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 325 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 326 | ) 327 | : JsonCodec_core.Codec.t(('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i)) => { 328 | let encode = ((v1, v2, v3, v4, v5, v6, v7, v8, v9)) => 329 | Js.Json.object_ @@ 330 | JsonCodec_util.buildDict([ 331 | enc1(v1), 332 | enc2(v2), 333 | enc3(v3), 334 | enc4(v4), 335 | enc5(v5), 336 | enc6(v6), 337 | enc7(v7), 338 | enc8(v8), 339 | enc9(v9), 340 | ]); 341 | let decode = json => 342 | JsonCodec_util.decodeRawObject(json) 343 | >>= ( 344 | dict => 345 | dec1(dict) 346 | >>= ( 347 | v1 => 348 | dec2(dict) 349 | >>= ( 350 | v2 => 351 | dec3(dict) 352 | >>= ( 353 | v3 => 354 | dec4(dict) 355 | >>= ( 356 | v4 => 357 | dec5(dict) 358 | >>= ( 359 | v5 => 360 | dec6(dict) 361 | >>= ( 362 | v6 => 363 | dec7(dict) 364 | >>= ( 365 | v7 => 366 | dec8(dict) 367 | >>= ( 368 | v8 => 369 | dec9(dict) 370 | >>= ( 371 | v9 => 372 | Belt.Result.Ok(( 373 | v1, 374 | v2, 375 | v3, 376 | v4, 377 | v5, 378 | v6, 379 | v7, 380 | v8, 381 | v9, 382 | )) 383 | ) 384 | ) 385 | ) 386 | ) 387 | ) 388 | ) 389 | ) 390 | ) 391 | ) 392 | ); 393 | (encode, decode); 394 | }; 395 | let object10 = 396 | ( 397 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 398 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 399 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 400 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 401 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 402 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 403 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 404 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 405 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 406 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 407 | ) 408 | : JsonCodec_core.Codec.t(('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j)) => { 409 | let encode = ((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10)) => 410 | Js.Json.object_ @@ 411 | JsonCodec_util.buildDict([ 412 | enc1(v1), 413 | enc2(v2), 414 | enc3(v3), 415 | enc4(v4), 416 | enc5(v5), 417 | enc6(v6), 418 | enc7(v7), 419 | enc8(v8), 420 | enc9(v9), 421 | enc10(v10), 422 | ]); 423 | let decode = json => 424 | JsonCodec_util.decodeRawObject(json) 425 | >>= ( 426 | dict => 427 | dec1(dict) 428 | >>= ( 429 | v1 => 430 | dec2(dict) 431 | >>= ( 432 | v2 => 433 | dec3(dict) 434 | >>= ( 435 | v3 => 436 | dec4(dict) 437 | >>= ( 438 | v4 => 439 | dec5(dict) 440 | >>= ( 441 | v5 => 442 | dec6(dict) 443 | >>= ( 444 | v6 => 445 | dec7(dict) 446 | >>= ( 447 | v7 => 448 | dec8(dict) 449 | >>= ( 450 | v8 => 451 | dec9(dict) 452 | >>= ( 453 | v9 => 454 | dec10(dict) 455 | >>= ( 456 | v10 => 457 | Belt.Result.Ok(( 458 | v1, 459 | v2, 460 | v3, 461 | v4, 462 | v5, 463 | v6, 464 | v7, 465 | v8, 466 | v9, 467 | v10, 468 | )) 469 | ) 470 | ) 471 | ) 472 | ) 473 | ) 474 | ) 475 | ) 476 | ) 477 | ) 478 | ) 479 | ); 480 | (encode, decode); 481 | }; 482 | let object11 = 483 | ( 484 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 485 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 486 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 487 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 488 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 489 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 490 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 491 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 492 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 493 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 494 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 495 | ) 496 | : JsonCodec_core.Codec.t(('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k)) => { 497 | let encode = ((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)) => 498 | Js.Json.object_ @@ 499 | JsonCodec_util.buildDict([ 500 | enc1(v1), 501 | enc2(v2), 502 | enc3(v3), 503 | enc4(v4), 504 | enc5(v5), 505 | enc6(v6), 506 | enc7(v7), 507 | enc8(v8), 508 | enc9(v9), 509 | enc10(v10), 510 | enc11(v11), 511 | ]); 512 | let decode = json => 513 | JsonCodec_util.decodeRawObject(json) 514 | >>= ( 515 | dict => 516 | dec1(dict) 517 | >>= ( 518 | v1 => 519 | dec2(dict) 520 | >>= ( 521 | v2 => 522 | dec3(dict) 523 | >>= ( 524 | v3 => 525 | dec4(dict) 526 | >>= ( 527 | v4 => 528 | dec5(dict) 529 | >>= ( 530 | v5 => 531 | dec6(dict) 532 | >>= ( 533 | v6 => 534 | dec7(dict) 535 | >>= ( 536 | v7 => 537 | dec8(dict) 538 | >>= ( 539 | v8 => 540 | dec9(dict) 541 | >>= ( 542 | v9 => 543 | dec10(dict) 544 | >>= ( 545 | v10 => 546 | dec11(dict) 547 | >>= ( 548 | v11 => 549 | Belt.Result.Ok(( 550 | v1, 551 | v2, 552 | v3, 553 | v4, 554 | v5, 555 | v6, 556 | v7, 557 | v8, 558 | v9, 559 | v10, 560 | v11, 561 | )) 562 | ) 563 | ) 564 | ) 565 | ) 566 | ) 567 | ) 568 | ) 569 | ) 570 | ) 571 | ) 572 | ) 573 | ); 574 | (encode, decode); 575 | }; 576 | let object12 = 577 | ( 578 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 579 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 580 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 581 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 582 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 583 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 584 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 585 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 586 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 587 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 588 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 589 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 590 | ) 591 | : JsonCodec_core.Codec.t( 592 | ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l), 593 | ) => { 594 | let encode = ((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)) => 595 | Js.Json.object_ @@ 596 | JsonCodec_util.buildDict([ 597 | enc1(v1), 598 | enc2(v2), 599 | enc3(v3), 600 | enc4(v4), 601 | enc5(v5), 602 | enc6(v6), 603 | enc7(v7), 604 | enc8(v8), 605 | enc9(v9), 606 | enc10(v10), 607 | enc11(v11), 608 | enc12(v12), 609 | ]); 610 | let decode = json => 611 | JsonCodec_util.decodeRawObject(json) 612 | >>= ( 613 | dict => 614 | dec1(dict) 615 | >>= ( 616 | v1 => 617 | dec2(dict) 618 | >>= ( 619 | v2 => 620 | dec3(dict) 621 | >>= ( 622 | v3 => 623 | dec4(dict) 624 | >>= ( 625 | v4 => 626 | dec5(dict) 627 | >>= ( 628 | v5 => 629 | dec6(dict) 630 | >>= ( 631 | v6 => 632 | dec7(dict) 633 | >>= ( 634 | v7 => 635 | dec8(dict) 636 | >>= ( 637 | v8 => 638 | dec9(dict) 639 | >>= ( 640 | v9 => 641 | dec10(dict) 642 | >>= ( 643 | v10 => 644 | dec11(dict) 645 | >>= ( 646 | v11 => 647 | dec12(dict) 648 | >>= ( 649 | v12 => 650 | Belt.Result.Ok(( 651 | v1, 652 | v2, 653 | v3, 654 | v4, 655 | v5, 656 | v6, 657 | v7, 658 | v8, 659 | v9, 660 | v10, 661 | v11, 662 | v12, 663 | )) 664 | ) 665 | ) 666 | ) 667 | ) 668 | ) 669 | ) 670 | ) 671 | ) 672 | ) 673 | ) 674 | ) 675 | ) 676 | ); 677 | (encode, decode); 678 | }; 679 | let object13 = 680 | ( 681 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 682 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 683 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 684 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 685 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 686 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 687 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 688 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 689 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 690 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 691 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 692 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 693 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 694 | ) 695 | : JsonCodec_core.Codec.t( 696 | ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm), 697 | ) => { 698 | let encode = ((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)) => 699 | Js.Json.object_ @@ 700 | JsonCodec_util.buildDict([ 701 | enc1(v1), 702 | enc2(v2), 703 | enc3(v3), 704 | enc4(v4), 705 | enc5(v5), 706 | enc6(v6), 707 | enc7(v7), 708 | enc8(v8), 709 | enc9(v9), 710 | enc10(v10), 711 | enc11(v11), 712 | enc12(v12), 713 | enc13(v13), 714 | ]); 715 | let decode = json => 716 | JsonCodec_util.decodeRawObject(json) 717 | >>= ( 718 | dict => 719 | dec1(dict) 720 | >>= ( 721 | v1 => 722 | dec2(dict) 723 | >>= ( 724 | v2 => 725 | dec3(dict) 726 | >>= ( 727 | v3 => 728 | dec4(dict) 729 | >>= ( 730 | v4 => 731 | dec5(dict) 732 | >>= ( 733 | v5 => 734 | dec6(dict) 735 | >>= ( 736 | v6 => 737 | dec7(dict) 738 | >>= ( 739 | v7 => 740 | dec8(dict) 741 | >>= ( 742 | v8 => 743 | dec9(dict) 744 | >>= ( 745 | v9 => 746 | dec10(dict) 747 | >>= ( 748 | v10 => 749 | dec11(dict) 750 | >>= ( 751 | v11 => 752 | dec12(dict) 753 | >>= ( 754 | v12 => 755 | dec13(dict) 756 | >>= ( 757 | v13 => 758 | Belt.Result.Ok(( 759 | v1, 760 | v2, 761 | v3, 762 | v4, 763 | v5, 764 | v6, 765 | v7, 766 | v8, 767 | v9, 768 | v10, 769 | v11, 770 | v12, 771 | v13, 772 | )) 773 | ) 774 | ) 775 | ) 776 | ) 777 | ) 778 | ) 779 | ) 780 | ) 781 | ) 782 | ) 783 | ) 784 | ) 785 | ) 786 | ); 787 | (encode, decode); 788 | }; 789 | let object14 = 790 | ( 791 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 792 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 793 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 794 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 795 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 796 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 797 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 798 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 799 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 800 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 801 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 802 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 803 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 804 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 805 | ) 806 | : JsonCodec_core.Codec.t( 807 | ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n), 808 | ) => { 809 | let encode = 810 | ((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)) => 811 | Js.Json.object_ @@ 812 | JsonCodec_util.buildDict([ 813 | enc1(v1), 814 | enc2(v2), 815 | enc3(v3), 816 | enc4(v4), 817 | enc5(v5), 818 | enc6(v6), 819 | enc7(v7), 820 | enc8(v8), 821 | enc9(v9), 822 | enc10(v10), 823 | enc11(v11), 824 | enc12(v12), 825 | enc13(v13), 826 | enc14(v14), 827 | ]); 828 | let decode = json => 829 | JsonCodec_util.decodeRawObject(json) 830 | >>= ( 831 | dict => 832 | dec1(dict) 833 | >>= ( 834 | v1 => 835 | dec2(dict) 836 | >>= ( 837 | v2 => 838 | dec3(dict) 839 | >>= ( 840 | v3 => 841 | dec4(dict) 842 | >>= ( 843 | v4 => 844 | dec5(dict) 845 | >>= ( 846 | v5 => 847 | dec6(dict) 848 | >>= ( 849 | v6 => 850 | dec7(dict) 851 | >>= ( 852 | v7 => 853 | dec8(dict) 854 | >>= ( 855 | v8 => 856 | dec9(dict) 857 | >>= ( 858 | v9 => 859 | dec10(dict) 860 | >>= ( 861 | v10 => 862 | dec11(dict) 863 | >>= ( 864 | v11 => 865 | dec12(dict) 866 | >>= ( 867 | v12 => 868 | dec13(dict) 869 | >>= ( 870 | v13 => 871 | dec14(dict) 872 | >>= ( 873 | v14 => 874 | Belt.Result.Ok(( 875 | v1, 876 | v2, 877 | v3, 878 | v4, 879 | v5, 880 | v6, 881 | v7, 882 | v8, 883 | v9, 884 | v10, 885 | v11, 886 | v12, 887 | v13, 888 | v14, 889 | )) 890 | ) 891 | ) 892 | ) 893 | ) 894 | ) 895 | ) 896 | ) 897 | ) 898 | ) 899 | ) 900 | ) 901 | ) 902 | ) 903 | ) 904 | ); 905 | (encode, decode); 906 | }; 907 | let object15 = 908 | ( 909 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 910 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 911 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 912 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 913 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 914 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 915 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 916 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 917 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 918 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 919 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 920 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 921 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 922 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 923 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 924 | ) 925 | : JsonCodec_core.Codec.t( 926 | ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o), 927 | ) => { 928 | let encode = 929 | ((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)) => 930 | Js.Json.object_ @@ 931 | JsonCodec_util.buildDict([ 932 | enc1(v1), 933 | enc2(v2), 934 | enc3(v3), 935 | enc4(v4), 936 | enc5(v5), 937 | enc6(v6), 938 | enc7(v7), 939 | enc8(v8), 940 | enc9(v9), 941 | enc10(v10), 942 | enc11(v11), 943 | enc12(v12), 944 | enc13(v13), 945 | enc14(v14), 946 | enc15(v15), 947 | ]); 948 | let decode = json => 949 | JsonCodec_util.decodeRawObject(json) 950 | >>= ( 951 | dict => 952 | dec1(dict) 953 | >>= ( 954 | v1 => 955 | dec2(dict) 956 | >>= ( 957 | v2 => 958 | dec3(dict) 959 | >>= ( 960 | v3 => 961 | dec4(dict) 962 | >>= ( 963 | v4 => 964 | dec5(dict) 965 | >>= ( 966 | v5 => 967 | dec6(dict) 968 | >>= ( 969 | v6 => 970 | dec7(dict) 971 | >>= ( 972 | v7 => 973 | dec8(dict) 974 | >>= ( 975 | v8 => 976 | dec9(dict) 977 | >>= ( 978 | v9 => 979 | dec10(dict) 980 | >>= ( 981 | v10 => 982 | dec11(dict) 983 | >>= ( 984 | v11 => 985 | dec12(dict) 986 | >>= ( 987 | v12 => 988 | dec13(dict) 989 | >>= ( 990 | v13 => 991 | dec14(dict) 992 | >>= ( 993 | v14 => 994 | dec15(dict) 995 | >>= ( 996 | v15 => 997 | Belt.Result.Ok(( 998 | v1, 999 | v2, 1000 | v3, 1001 | v4, 1002 | v5, 1003 | v6, 1004 | v7, 1005 | v8, 1006 | v9, 1007 | v10, 1008 | v11, 1009 | v12, 1010 | v13, 1011 | v14, 1012 | v15, 1013 | )) 1014 | ) 1015 | ) 1016 | ) 1017 | ) 1018 | ) 1019 | ) 1020 | ) 1021 | ) 1022 | ) 1023 | ) 1024 | ) 1025 | ) 1026 | ) 1027 | ) 1028 | ) 1029 | ); 1030 | (encode, decode); 1031 | }; 1032 | let object16 = 1033 | ( 1034 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 1035 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 1036 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 1037 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 1038 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 1039 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 1040 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 1041 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 1042 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 1043 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 1044 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 1045 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 1046 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 1047 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 1048 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 1049 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 1050 | ) 1051 | : JsonCodec_core.Codec.t( 1052 | ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p), 1053 | ) => { 1054 | let encode = 1055 | ( 1056 | ( 1057 | v1, 1058 | v2, 1059 | v3, 1060 | v4, 1061 | v5, 1062 | v6, 1063 | v7, 1064 | v8, 1065 | v9, 1066 | v10, 1067 | v11, 1068 | v12, 1069 | v13, 1070 | v14, 1071 | v15, 1072 | v16, 1073 | ), 1074 | ) => 1075 | Js.Json.object_ @@ 1076 | JsonCodec_util.buildDict([ 1077 | enc1(v1), 1078 | enc2(v2), 1079 | enc3(v3), 1080 | enc4(v4), 1081 | enc5(v5), 1082 | enc6(v6), 1083 | enc7(v7), 1084 | enc8(v8), 1085 | enc9(v9), 1086 | enc10(v10), 1087 | enc11(v11), 1088 | enc12(v12), 1089 | enc13(v13), 1090 | enc14(v14), 1091 | enc15(v15), 1092 | enc16(v16), 1093 | ]); 1094 | let decode = json => 1095 | JsonCodec_util.decodeRawObject(json) 1096 | >>= ( 1097 | dict => 1098 | dec1(dict) 1099 | >>= ( 1100 | v1 => 1101 | dec2(dict) 1102 | >>= ( 1103 | v2 => 1104 | dec3(dict) 1105 | >>= ( 1106 | v3 => 1107 | dec4(dict) 1108 | >>= ( 1109 | v4 => 1110 | dec5(dict) 1111 | >>= ( 1112 | v5 => 1113 | dec6(dict) 1114 | >>= ( 1115 | v6 => 1116 | dec7(dict) 1117 | >>= ( 1118 | v7 => 1119 | dec8(dict) 1120 | >>= ( 1121 | v8 => 1122 | dec9(dict) 1123 | >>= ( 1124 | v9 => 1125 | dec10(dict) 1126 | >>= ( 1127 | v10 => 1128 | dec11(dict) 1129 | >>= ( 1130 | v11 => 1131 | dec12(dict) 1132 | >>= ( 1133 | v12 => 1134 | dec13(dict) 1135 | >>= ( 1136 | v13 => 1137 | dec14(dict) 1138 | >>= ( 1139 | v14 => 1140 | dec15(dict) 1141 | >>= ( 1142 | v15 => 1143 | dec16( 1144 | dict, 1145 | ) 1146 | >>= ( 1147 | v16 => 1148 | Belt.Result.Ok(( 1149 | v1, 1150 | v2, 1151 | v3, 1152 | v4, 1153 | v5, 1154 | v6, 1155 | v7, 1156 | v8, 1157 | v9, 1158 | v10, 1159 | v11, 1160 | v12, 1161 | v13, 1162 | v14, 1163 | v15, 1164 | v16, 1165 | )) 1166 | ) 1167 | ) 1168 | ) 1169 | ) 1170 | ) 1171 | ) 1172 | ) 1173 | ) 1174 | ) 1175 | ) 1176 | ) 1177 | ) 1178 | ) 1179 | ) 1180 | ) 1181 | ) 1182 | ); 1183 | (encode, decode); 1184 | }; 1185 | let object17 = 1186 | ( 1187 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 1188 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 1189 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 1190 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 1191 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 1192 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 1193 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 1194 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 1195 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 1196 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 1197 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 1198 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 1199 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 1200 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 1201 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 1202 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 1203 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 1204 | ) 1205 | : JsonCodec_core.Codec.t( 1206 | ('a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, 'q), 1207 | ) => { 1208 | let encode = 1209 | ( 1210 | ( 1211 | v1, 1212 | v2, 1213 | v3, 1214 | v4, 1215 | v5, 1216 | v6, 1217 | v7, 1218 | v8, 1219 | v9, 1220 | v10, 1221 | v11, 1222 | v12, 1223 | v13, 1224 | v14, 1225 | v15, 1226 | v16, 1227 | v17, 1228 | ), 1229 | ) => 1230 | Js.Json.object_ @@ 1231 | JsonCodec_util.buildDict([ 1232 | enc1(v1), 1233 | enc2(v2), 1234 | enc3(v3), 1235 | enc4(v4), 1236 | enc5(v5), 1237 | enc6(v6), 1238 | enc7(v7), 1239 | enc8(v8), 1240 | enc9(v9), 1241 | enc10(v10), 1242 | enc11(v11), 1243 | enc12(v12), 1244 | enc13(v13), 1245 | enc14(v14), 1246 | enc15(v15), 1247 | enc16(v16), 1248 | enc17(v17), 1249 | ]); 1250 | let decode = json => 1251 | JsonCodec_util.decodeRawObject(json) 1252 | >>= ( 1253 | dict => 1254 | dec1(dict) 1255 | >>= ( 1256 | v1 => 1257 | dec2(dict) 1258 | >>= ( 1259 | v2 => 1260 | dec3(dict) 1261 | >>= ( 1262 | v3 => 1263 | dec4(dict) 1264 | >>= ( 1265 | v4 => 1266 | dec5(dict) 1267 | >>= ( 1268 | v5 => 1269 | dec6(dict) 1270 | >>= ( 1271 | v6 => 1272 | dec7(dict) 1273 | >>= ( 1274 | v7 => 1275 | dec8(dict) 1276 | >>= ( 1277 | v8 => 1278 | dec9(dict) 1279 | >>= ( 1280 | v9 => 1281 | dec10(dict) 1282 | >>= ( 1283 | v10 => 1284 | dec11(dict) 1285 | >>= ( 1286 | v11 => 1287 | dec12(dict) 1288 | >>= ( 1289 | v12 => 1290 | dec13(dict) 1291 | >>= ( 1292 | v13 => 1293 | dec14(dict) 1294 | >>= ( 1295 | v14 => 1296 | dec15(dict) 1297 | >>= ( 1298 | v15 => 1299 | dec16( 1300 | dict, 1301 | ) 1302 | >>= ( 1303 | v16 => 1304 | dec17( 1305 | dict, 1306 | ) 1307 | >>= ( 1308 | v17 => 1309 | Belt.Result.Ok(( 1310 | v1, 1311 | v2, 1312 | v3, 1313 | v4, 1314 | v5, 1315 | v6, 1316 | v7, 1317 | v8, 1318 | v9, 1319 | v10, 1320 | v11, 1321 | v12, 1322 | v13, 1323 | v14, 1324 | v15, 1325 | v16, 1326 | v17, 1327 | )) 1328 | ) 1329 | ) 1330 | ) 1331 | ) 1332 | ) 1333 | ) 1334 | ) 1335 | ) 1336 | ) 1337 | ) 1338 | ) 1339 | ) 1340 | ) 1341 | ) 1342 | ) 1343 | ) 1344 | ) 1345 | ); 1346 | (encode, decode); 1347 | }; 1348 | let object18 = 1349 | ( 1350 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 1351 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 1352 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 1353 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 1354 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 1355 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 1356 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 1357 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 1358 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 1359 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 1360 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 1361 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 1362 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 1363 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 1364 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 1365 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 1366 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 1367 | (enc18, dec18): JsonCodec_core.FieldCodec.t('r), 1368 | ) 1369 | : JsonCodec_core.Codec.t( 1370 | ( 1371 | 'a, 1372 | 'b, 1373 | 'c, 1374 | 'd, 1375 | 'e, 1376 | 'f, 1377 | 'g, 1378 | 'h, 1379 | 'i, 1380 | 'j, 1381 | 'k, 1382 | 'l, 1383 | 'm, 1384 | 'n, 1385 | 'o, 1386 | 'p, 1387 | 'q, 1388 | 'r, 1389 | ), 1390 | ) => { 1391 | let encode = 1392 | ( 1393 | ( 1394 | v1, 1395 | v2, 1396 | v3, 1397 | v4, 1398 | v5, 1399 | v6, 1400 | v7, 1401 | v8, 1402 | v9, 1403 | v10, 1404 | v11, 1405 | v12, 1406 | v13, 1407 | v14, 1408 | v15, 1409 | v16, 1410 | v17, 1411 | v18, 1412 | ), 1413 | ) => 1414 | Js.Json.object_ @@ 1415 | JsonCodec_util.buildDict([ 1416 | enc1(v1), 1417 | enc2(v2), 1418 | enc3(v3), 1419 | enc4(v4), 1420 | enc5(v5), 1421 | enc6(v6), 1422 | enc7(v7), 1423 | enc8(v8), 1424 | enc9(v9), 1425 | enc10(v10), 1426 | enc11(v11), 1427 | enc12(v12), 1428 | enc13(v13), 1429 | enc14(v14), 1430 | enc15(v15), 1431 | enc16(v16), 1432 | enc17(v17), 1433 | enc18(v18), 1434 | ]); 1435 | let decode = json => 1436 | JsonCodec_util.decodeRawObject(json) 1437 | >>= ( 1438 | dict => 1439 | dec1(dict) 1440 | >>= ( 1441 | v1 => 1442 | dec2(dict) 1443 | >>= ( 1444 | v2 => 1445 | dec3(dict) 1446 | >>= ( 1447 | v3 => 1448 | dec4(dict) 1449 | >>= ( 1450 | v4 => 1451 | dec5(dict) 1452 | >>= ( 1453 | v5 => 1454 | dec6(dict) 1455 | >>= ( 1456 | v6 => 1457 | dec7(dict) 1458 | >>= ( 1459 | v7 => 1460 | dec8(dict) 1461 | >>= ( 1462 | v8 => 1463 | dec9(dict) 1464 | >>= ( 1465 | v9 => 1466 | dec10(dict) 1467 | >>= ( 1468 | v10 => 1469 | dec11(dict) 1470 | >>= ( 1471 | v11 => 1472 | dec12(dict) 1473 | >>= ( 1474 | v12 => 1475 | dec13(dict) 1476 | >>= ( 1477 | v13 => 1478 | dec14(dict) 1479 | >>= ( 1480 | v14 => 1481 | dec15(dict) 1482 | >>= ( 1483 | v15 => 1484 | dec16( 1485 | dict, 1486 | ) 1487 | >>= ( 1488 | v16 => 1489 | dec17( 1490 | dict, 1491 | ) 1492 | >>= ( 1493 | v17 => 1494 | dec18( 1495 | dict, 1496 | ) 1497 | >>= ( 1498 | v18 => 1499 | Belt.Result.Ok(( 1500 | v1, 1501 | v2, 1502 | v3, 1503 | v4, 1504 | v5, 1505 | v6, 1506 | v7, 1507 | v8, 1508 | v9, 1509 | v10, 1510 | v11, 1511 | v12, 1512 | v13, 1513 | v14, 1514 | v15, 1515 | v16, 1516 | v17, 1517 | v18, 1518 | )) 1519 | ) 1520 | ) 1521 | ) 1522 | ) 1523 | ) 1524 | ) 1525 | ) 1526 | ) 1527 | ) 1528 | ) 1529 | ) 1530 | ) 1531 | ) 1532 | ) 1533 | ) 1534 | ) 1535 | ) 1536 | ) 1537 | ); 1538 | (encode, decode); 1539 | }; 1540 | let object19 = 1541 | ( 1542 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 1543 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 1544 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 1545 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 1546 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 1547 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 1548 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 1549 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 1550 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 1551 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 1552 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 1553 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 1554 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 1555 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 1556 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 1557 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 1558 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 1559 | (enc18, dec18): JsonCodec_core.FieldCodec.t('r), 1560 | (enc19, dec19): JsonCodec_core.FieldCodec.t('s), 1561 | ) 1562 | : JsonCodec_core.Codec.t( 1563 | ( 1564 | 'a, 1565 | 'b, 1566 | 'c, 1567 | 'd, 1568 | 'e, 1569 | 'f, 1570 | 'g, 1571 | 'h, 1572 | 'i, 1573 | 'j, 1574 | 'k, 1575 | 'l, 1576 | 'm, 1577 | 'n, 1578 | 'o, 1579 | 'p, 1580 | 'q, 1581 | 'r, 1582 | 's, 1583 | ), 1584 | ) => { 1585 | let encode = 1586 | ( 1587 | ( 1588 | v1, 1589 | v2, 1590 | v3, 1591 | v4, 1592 | v5, 1593 | v6, 1594 | v7, 1595 | v8, 1596 | v9, 1597 | v10, 1598 | v11, 1599 | v12, 1600 | v13, 1601 | v14, 1602 | v15, 1603 | v16, 1604 | v17, 1605 | v18, 1606 | v19, 1607 | ), 1608 | ) => 1609 | Js.Json.object_ @@ 1610 | JsonCodec_util.buildDict([ 1611 | enc1(v1), 1612 | enc2(v2), 1613 | enc3(v3), 1614 | enc4(v4), 1615 | enc5(v5), 1616 | enc6(v6), 1617 | enc7(v7), 1618 | enc8(v8), 1619 | enc9(v9), 1620 | enc10(v10), 1621 | enc11(v11), 1622 | enc12(v12), 1623 | enc13(v13), 1624 | enc14(v14), 1625 | enc15(v15), 1626 | enc16(v16), 1627 | enc17(v17), 1628 | enc18(v18), 1629 | enc19(v19), 1630 | ]); 1631 | let decode = json => 1632 | JsonCodec_util.decodeRawObject(json) 1633 | >>= ( 1634 | dict => 1635 | dec1(dict) 1636 | >>= ( 1637 | v1 => 1638 | dec2(dict) 1639 | >>= ( 1640 | v2 => 1641 | dec3(dict) 1642 | >>= ( 1643 | v3 => 1644 | dec4(dict) 1645 | >>= ( 1646 | v4 => 1647 | dec5(dict) 1648 | >>= ( 1649 | v5 => 1650 | dec6(dict) 1651 | >>= ( 1652 | v6 => 1653 | dec7(dict) 1654 | >>= ( 1655 | v7 => 1656 | dec8(dict) 1657 | >>= ( 1658 | v8 => 1659 | dec9(dict) 1660 | >>= ( 1661 | v9 => 1662 | dec10(dict) 1663 | >>= ( 1664 | v10 => 1665 | dec11(dict) 1666 | >>= ( 1667 | v11 => 1668 | dec12(dict) 1669 | >>= ( 1670 | v12 => 1671 | dec13(dict) 1672 | >>= ( 1673 | v13 => 1674 | dec14(dict) 1675 | >>= ( 1676 | v14 => 1677 | dec15(dict) 1678 | >>= ( 1679 | v15 => 1680 | dec16( 1681 | dict, 1682 | ) 1683 | >>= ( 1684 | v16 => 1685 | dec17( 1686 | dict, 1687 | ) 1688 | >>= ( 1689 | v17 => 1690 | dec18( 1691 | dict, 1692 | ) 1693 | >>= ( 1694 | v18 => 1695 | dec19( 1696 | dict, 1697 | ) 1698 | >>= ( 1699 | v19 => 1700 | Belt.Result.Ok(( 1701 | v1, 1702 | v2, 1703 | v3, 1704 | v4, 1705 | v5, 1706 | v6, 1707 | v7, 1708 | v8, 1709 | v9, 1710 | v10, 1711 | v11, 1712 | v12, 1713 | v13, 1714 | v14, 1715 | v15, 1716 | v16, 1717 | v17, 1718 | v18, 1719 | v19, 1720 | )) 1721 | ) 1722 | ) 1723 | ) 1724 | ) 1725 | ) 1726 | ) 1727 | ) 1728 | ) 1729 | ) 1730 | ) 1731 | ) 1732 | ) 1733 | ) 1734 | ) 1735 | ) 1736 | ) 1737 | ) 1738 | ) 1739 | ) 1740 | ); 1741 | (encode, decode); 1742 | }; 1743 | let object20 = 1744 | ( 1745 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 1746 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 1747 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 1748 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 1749 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 1750 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 1751 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 1752 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 1753 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 1754 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 1755 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 1756 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 1757 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 1758 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 1759 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 1760 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 1761 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 1762 | (enc18, dec18): JsonCodec_core.FieldCodec.t('r), 1763 | (enc19, dec19): JsonCodec_core.FieldCodec.t('s), 1764 | (enc20, dec20): JsonCodec_core.FieldCodec.t('t), 1765 | ) 1766 | : JsonCodec_core.Codec.t( 1767 | ( 1768 | 'a, 1769 | 'b, 1770 | 'c, 1771 | 'd, 1772 | 'e, 1773 | 'f, 1774 | 'g, 1775 | 'h, 1776 | 'i, 1777 | 'j, 1778 | 'k, 1779 | 'l, 1780 | 'm, 1781 | 'n, 1782 | 'o, 1783 | 'p, 1784 | 'q, 1785 | 'r, 1786 | 's, 1787 | 't, 1788 | ), 1789 | ) => { 1790 | let encode = 1791 | ( 1792 | ( 1793 | v1, 1794 | v2, 1795 | v3, 1796 | v4, 1797 | v5, 1798 | v6, 1799 | v7, 1800 | v8, 1801 | v9, 1802 | v10, 1803 | v11, 1804 | v12, 1805 | v13, 1806 | v14, 1807 | v15, 1808 | v16, 1809 | v17, 1810 | v18, 1811 | v19, 1812 | v20, 1813 | ), 1814 | ) => 1815 | Js.Json.object_ @@ 1816 | JsonCodec_util.buildDict([ 1817 | enc1(v1), 1818 | enc2(v2), 1819 | enc3(v3), 1820 | enc4(v4), 1821 | enc5(v5), 1822 | enc6(v6), 1823 | enc7(v7), 1824 | enc8(v8), 1825 | enc9(v9), 1826 | enc10(v10), 1827 | enc11(v11), 1828 | enc12(v12), 1829 | enc13(v13), 1830 | enc14(v14), 1831 | enc15(v15), 1832 | enc16(v16), 1833 | enc17(v17), 1834 | enc18(v18), 1835 | enc19(v19), 1836 | enc20(v20), 1837 | ]); 1838 | let decode = json => 1839 | JsonCodec_util.decodeRawObject(json) 1840 | >>= ( 1841 | dict => 1842 | dec1(dict) 1843 | >>= ( 1844 | v1 => 1845 | dec2(dict) 1846 | >>= ( 1847 | v2 => 1848 | dec3(dict) 1849 | >>= ( 1850 | v3 => 1851 | dec4(dict) 1852 | >>= ( 1853 | v4 => 1854 | dec5(dict) 1855 | >>= ( 1856 | v5 => 1857 | dec6(dict) 1858 | >>= ( 1859 | v6 => 1860 | dec7(dict) 1861 | >>= ( 1862 | v7 => 1863 | dec8(dict) 1864 | >>= ( 1865 | v8 => 1866 | dec9(dict) 1867 | >>= ( 1868 | v9 => 1869 | dec10(dict) 1870 | >>= ( 1871 | v10 => 1872 | dec11(dict) 1873 | >>= ( 1874 | v11 => 1875 | dec12(dict) 1876 | >>= ( 1877 | v12 => 1878 | dec13(dict) 1879 | >>= ( 1880 | v13 => 1881 | dec14(dict) 1882 | >>= ( 1883 | v14 => 1884 | dec15(dict) 1885 | >>= ( 1886 | v15 => 1887 | dec16( 1888 | dict, 1889 | ) 1890 | >>= ( 1891 | v16 => 1892 | dec17( 1893 | dict, 1894 | ) 1895 | >>= ( 1896 | v17 => 1897 | dec18( 1898 | dict, 1899 | ) 1900 | >>= ( 1901 | v18 => 1902 | dec19( 1903 | dict, 1904 | ) 1905 | >>= ( 1906 | v19 => 1907 | dec20( 1908 | dict, 1909 | ) 1910 | >>= ( 1911 | v20 => 1912 | Belt.Result.Ok(( 1913 | v1, 1914 | v2, 1915 | v3, 1916 | v4, 1917 | v5, 1918 | v6, 1919 | v7, 1920 | v8, 1921 | v9, 1922 | v10, 1923 | v11, 1924 | v12, 1925 | v13, 1926 | v14, 1927 | v15, 1928 | v16, 1929 | v17, 1930 | v18, 1931 | v19, 1932 | v20, 1933 | )) 1934 | ) 1935 | ) 1936 | ) 1937 | ) 1938 | ) 1939 | ) 1940 | ) 1941 | ) 1942 | ) 1943 | ) 1944 | ) 1945 | ) 1946 | ) 1947 | ) 1948 | ) 1949 | ) 1950 | ) 1951 | ) 1952 | ) 1953 | ) 1954 | ); 1955 | (encode, decode); 1956 | }; 1957 | let object21 = 1958 | ( 1959 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 1960 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 1961 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 1962 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 1963 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 1964 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 1965 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 1966 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 1967 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 1968 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 1969 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 1970 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 1971 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 1972 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 1973 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 1974 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 1975 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 1976 | (enc18, dec18): JsonCodec_core.FieldCodec.t('r), 1977 | (enc19, dec19): JsonCodec_core.FieldCodec.t('s), 1978 | (enc20, dec20): JsonCodec_core.FieldCodec.t('t), 1979 | (enc21, dec21): JsonCodec_core.FieldCodec.t('u), 1980 | ) 1981 | : JsonCodec_core.Codec.t( 1982 | ( 1983 | 'a, 1984 | 'b, 1985 | 'c, 1986 | 'd, 1987 | 'e, 1988 | 'f, 1989 | 'g, 1990 | 'h, 1991 | 'i, 1992 | 'j, 1993 | 'k, 1994 | 'l, 1995 | 'm, 1996 | 'n, 1997 | 'o, 1998 | 'p, 1999 | 'q, 2000 | 'r, 2001 | 's, 2002 | 't, 2003 | 'u, 2004 | ), 2005 | ) => { 2006 | let encode = 2007 | ( 2008 | ( 2009 | v1, 2010 | v2, 2011 | v3, 2012 | v4, 2013 | v5, 2014 | v6, 2015 | v7, 2016 | v8, 2017 | v9, 2018 | v10, 2019 | v11, 2020 | v12, 2021 | v13, 2022 | v14, 2023 | v15, 2024 | v16, 2025 | v17, 2026 | v18, 2027 | v19, 2028 | v20, 2029 | v21, 2030 | ), 2031 | ) => 2032 | Js.Json.object_ @@ 2033 | JsonCodec_util.buildDict([ 2034 | enc1(v1), 2035 | enc2(v2), 2036 | enc3(v3), 2037 | enc4(v4), 2038 | enc5(v5), 2039 | enc6(v6), 2040 | enc7(v7), 2041 | enc8(v8), 2042 | enc9(v9), 2043 | enc10(v10), 2044 | enc11(v11), 2045 | enc12(v12), 2046 | enc13(v13), 2047 | enc14(v14), 2048 | enc15(v15), 2049 | enc16(v16), 2050 | enc17(v17), 2051 | enc18(v18), 2052 | enc19(v19), 2053 | enc20(v20), 2054 | enc21(v21), 2055 | ]); 2056 | let decode = json => 2057 | JsonCodec_util.decodeRawObject(json) 2058 | >>= ( 2059 | dict => 2060 | dec1(dict) 2061 | >>= ( 2062 | v1 => 2063 | dec2(dict) 2064 | >>= ( 2065 | v2 => 2066 | dec3(dict) 2067 | >>= ( 2068 | v3 => 2069 | dec4(dict) 2070 | >>= ( 2071 | v4 => 2072 | dec5(dict) 2073 | >>= ( 2074 | v5 => 2075 | dec6(dict) 2076 | >>= ( 2077 | v6 => 2078 | dec7(dict) 2079 | >>= ( 2080 | v7 => 2081 | dec8(dict) 2082 | >>= ( 2083 | v8 => 2084 | dec9(dict) 2085 | >>= ( 2086 | v9 => 2087 | dec10(dict) 2088 | >>= ( 2089 | v10 => 2090 | dec11(dict) 2091 | >>= ( 2092 | v11 => 2093 | dec12(dict) 2094 | >>= ( 2095 | v12 => 2096 | dec13(dict) 2097 | >>= ( 2098 | v13 => 2099 | dec14(dict) 2100 | >>= ( 2101 | v14 => 2102 | dec15(dict) 2103 | >>= ( 2104 | v15 => 2105 | dec16( 2106 | dict, 2107 | ) 2108 | >>= ( 2109 | v16 => 2110 | dec17( 2111 | dict, 2112 | ) 2113 | >>= ( 2114 | v17 => 2115 | dec18( 2116 | dict, 2117 | ) 2118 | >>= ( 2119 | v18 => 2120 | dec19( 2121 | dict, 2122 | ) 2123 | >>= ( 2124 | v19 => 2125 | dec20( 2126 | dict, 2127 | ) 2128 | >>= ( 2129 | v20 => 2130 | dec21( 2131 | dict, 2132 | ) 2133 | >>= ( 2134 | v21 => 2135 | Belt.Result.Ok(( 2136 | v1, 2137 | v2, 2138 | v3, 2139 | v4, 2140 | v5, 2141 | v6, 2142 | v7, 2143 | v8, 2144 | v9, 2145 | v10, 2146 | v11, 2147 | v12, 2148 | v13, 2149 | v14, 2150 | v15, 2151 | v16, 2152 | v17, 2153 | v18, 2154 | v19, 2155 | v20, 2156 | v21, 2157 | )) 2158 | ) 2159 | ) 2160 | ) 2161 | ) 2162 | ) 2163 | ) 2164 | ) 2165 | ) 2166 | ) 2167 | ) 2168 | ) 2169 | ) 2170 | ) 2171 | ) 2172 | ) 2173 | ) 2174 | ) 2175 | ) 2176 | ) 2177 | ) 2178 | ) 2179 | ); 2180 | (encode, decode); 2181 | }; 2182 | let object22 = 2183 | ( 2184 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 2185 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 2186 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 2187 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 2188 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 2189 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 2190 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 2191 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 2192 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 2193 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 2194 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 2195 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 2196 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 2197 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 2198 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 2199 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 2200 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 2201 | (enc18, dec18): JsonCodec_core.FieldCodec.t('r), 2202 | (enc19, dec19): JsonCodec_core.FieldCodec.t('s), 2203 | (enc20, dec20): JsonCodec_core.FieldCodec.t('t), 2204 | (enc21, dec21): JsonCodec_core.FieldCodec.t('u), 2205 | (enc22, dec22): JsonCodec_core.FieldCodec.t('v), 2206 | ) 2207 | : JsonCodec_core.Codec.t( 2208 | ( 2209 | 'a, 2210 | 'b, 2211 | 'c, 2212 | 'd, 2213 | 'e, 2214 | 'f, 2215 | 'g, 2216 | 'h, 2217 | 'i, 2218 | 'j, 2219 | 'k, 2220 | 'l, 2221 | 'm, 2222 | 'n, 2223 | 'o, 2224 | 'p, 2225 | 'q, 2226 | 'r, 2227 | 's, 2228 | 't, 2229 | 'u, 2230 | 'v, 2231 | ), 2232 | ) => { 2233 | let encode = 2234 | ( 2235 | ( 2236 | v1, 2237 | v2, 2238 | v3, 2239 | v4, 2240 | v5, 2241 | v6, 2242 | v7, 2243 | v8, 2244 | v9, 2245 | v10, 2246 | v11, 2247 | v12, 2248 | v13, 2249 | v14, 2250 | v15, 2251 | v16, 2252 | v17, 2253 | v18, 2254 | v19, 2255 | v20, 2256 | v21, 2257 | v22, 2258 | ), 2259 | ) => 2260 | Js.Json.object_ @@ 2261 | JsonCodec_util.buildDict([ 2262 | enc1(v1), 2263 | enc2(v2), 2264 | enc3(v3), 2265 | enc4(v4), 2266 | enc5(v5), 2267 | enc6(v6), 2268 | enc7(v7), 2269 | enc8(v8), 2270 | enc9(v9), 2271 | enc10(v10), 2272 | enc11(v11), 2273 | enc12(v12), 2274 | enc13(v13), 2275 | enc14(v14), 2276 | enc15(v15), 2277 | enc16(v16), 2278 | enc17(v17), 2279 | enc18(v18), 2280 | enc19(v19), 2281 | enc20(v20), 2282 | enc21(v21), 2283 | enc22(v22), 2284 | ]); 2285 | let decode = json => 2286 | JsonCodec_util.decodeRawObject(json) 2287 | >>= ( 2288 | dict => 2289 | dec1(dict) 2290 | >>= ( 2291 | v1 => 2292 | dec2(dict) 2293 | >>= ( 2294 | v2 => 2295 | dec3(dict) 2296 | >>= ( 2297 | v3 => 2298 | dec4(dict) 2299 | >>= ( 2300 | v4 => 2301 | dec5(dict) 2302 | >>= ( 2303 | v5 => 2304 | dec6(dict) 2305 | >>= ( 2306 | v6 => 2307 | dec7(dict) 2308 | >>= ( 2309 | v7 => 2310 | dec8(dict) 2311 | >>= ( 2312 | v8 => 2313 | dec9(dict) 2314 | >>= ( 2315 | v9 => 2316 | dec10(dict) 2317 | >>= ( 2318 | v10 => 2319 | dec11(dict) 2320 | >>= ( 2321 | v11 => 2322 | dec12(dict) 2323 | >>= ( 2324 | v12 => 2325 | dec13(dict) 2326 | >>= ( 2327 | v13 => 2328 | dec14(dict) 2329 | >>= ( 2330 | v14 => 2331 | dec15(dict) 2332 | >>= ( 2333 | v15 => 2334 | dec16( 2335 | dict, 2336 | ) 2337 | >>= ( 2338 | v16 => 2339 | dec17( 2340 | dict, 2341 | ) 2342 | >>= ( 2343 | v17 => 2344 | dec18( 2345 | dict, 2346 | ) 2347 | >>= ( 2348 | v18 => 2349 | dec19( 2350 | dict, 2351 | ) 2352 | >>= ( 2353 | v19 => 2354 | dec20( 2355 | dict, 2356 | ) 2357 | >>= ( 2358 | v20 => 2359 | dec21( 2360 | dict, 2361 | ) 2362 | >>= ( 2363 | v21 => 2364 | dec22( 2365 | dict, 2366 | ) 2367 | >>= ( 2368 | v22 => 2369 | Belt.Result.Ok(( 2370 | v1, 2371 | v2, 2372 | v3, 2373 | v4, 2374 | v5, 2375 | v6, 2376 | v7, 2377 | v8, 2378 | v9, 2379 | v10, 2380 | v11, 2381 | v12, 2382 | v13, 2383 | v14, 2384 | v15, 2385 | v16, 2386 | v17, 2387 | v18, 2388 | v19, 2389 | v20, 2390 | v21, 2391 | v22, 2392 | )) 2393 | ) 2394 | ) 2395 | ) 2396 | ) 2397 | ) 2398 | ) 2399 | ) 2400 | ) 2401 | ) 2402 | ) 2403 | ) 2404 | ) 2405 | ) 2406 | ) 2407 | ) 2408 | ) 2409 | ) 2410 | ) 2411 | ) 2412 | ) 2413 | ) 2414 | ) 2415 | ); 2416 | (encode, decode); 2417 | }; 2418 | let object23 = 2419 | ( 2420 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 2421 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 2422 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 2423 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 2424 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 2425 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 2426 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 2427 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 2428 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 2429 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 2430 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 2431 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 2432 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 2433 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 2434 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 2435 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 2436 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 2437 | (enc18, dec18): JsonCodec_core.FieldCodec.t('r), 2438 | (enc19, dec19): JsonCodec_core.FieldCodec.t('s), 2439 | (enc20, dec20): JsonCodec_core.FieldCodec.t('t), 2440 | (enc21, dec21): JsonCodec_core.FieldCodec.t('u), 2441 | (enc22, dec22): JsonCodec_core.FieldCodec.t('v), 2442 | (enc23, dec23): JsonCodec_core.FieldCodec.t('w), 2443 | ) 2444 | : JsonCodec_core.Codec.t( 2445 | ( 2446 | 'a, 2447 | 'b, 2448 | 'c, 2449 | 'd, 2450 | 'e, 2451 | 'f, 2452 | 'g, 2453 | 'h, 2454 | 'i, 2455 | 'j, 2456 | 'k, 2457 | 'l, 2458 | 'm, 2459 | 'n, 2460 | 'o, 2461 | 'p, 2462 | 'q, 2463 | 'r, 2464 | 's, 2465 | 't, 2466 | 'u, 2467 | 'v, 2468 | 'w, 2469 | ), 2470 | ) => { 2471 | let encode = 2472 | ( 2473 | ( 2474 | v1, 2475 | v2, 2476 | v3, 2477 | v4, 2478 | v5, 2479 | v6, 2480 | v7, 2481 | v8, 2482 | v9, 2483 | v10, 2484 | v11, 2485 | v12, 2486 | v13, 2487 | v14, 2488 | v15, 2489 | v16, 2490 | v17, 2491 | v18, 2492 | v19, 2493 | v20, 2494 | v21, 2495 | v22, 2496 | v23, 2497 | ), 2498 | ) => 2499 | Js.Json.object_ @@ 2500 | JsonCodec_util.buildDict([ 2501 | enc1(v1), 2502 | enc2(v2), 2503 | enc3(v3), 2504 | enc4(v4), 2505 | enc5(v5), 2506 | enc6(v6), 2507 | enc7(v7), 2508 | enc8(v8), 2509 | enc9(v9), 2510 | enc10(v10), 2511 | enc11(v11), 2512 | enc12(v12), 2513 | enc13(v13), 2514 | enc14(v14), 2515 | enc15(v15), 2516 | enc16(v16), 2517 | enc17(v17), 2518 | enc18(v18), 2519 | enc19(v19), 2520 | enc20(v20), 2521 | enc21(v21), 2522 | enc22(v22), 2523 | enc23(v23), 2524 | ]); 2525 | let decode = json => 2526 | JsonCodec_util.decodeRawObject(json) 2527 | >>= ( 2528 | dict => 2529 | dec1(dict) 2530 | >>= ( 2531 | v1 => 2532 | dec2(dict) 2533 | >>= ( 2534 | v2 => 2535 | dec3(dict) 2536 | >>= ( 2537 | v3 => 2538 | dec4(dict) 2539 | >>= ( 2540 | v4 => 2541 | dec5(dict) 2542 | >>= ( 2543 | v5 => 2544 | dec6(dict) 2545 | >>= ( 2546 | v6 => 2547 | dec7(dict) 2548 | >>= ( 2549 | v7 => 2550 | dec8(dict) 2551 | >>= ( 2552 | v8 => 2553 | dec9(dict) 2554 | >>= ( 2555 | v9 => 2556 | dec10(dict) 2557 | >>= ( 2558 | v10 => 2559 | dec11(dict) 2560 | >>= ( 2561 | v11 => 2562 | dec12(dict) 2563 | >>= ( 2564 | v12 => 2565 | dec13(dict) 2566 | >>= ( 2567 | v13 => 2568 | dec14(dict) 2569 | >>= ( 2570 | v14 => 2571 | dec15(dict) 2572 | >>= ( 2573 | v15 => 2574 | dec16( 2575 | dict, 2576 | ) 2577 | >>= ( 2578 | v16 => 2579 | dec17( 2580 | dict, 2581 | ) 2582 | >>= ( 2583 | v17 => 2584 | dec18( 2585 | dict, 2586 | ) 2587 | >>= ( 2588 | v18 => 2589 | dec19( 2590 | dict, 2591 | ) 2592 | >>= ( 2593 | v19 => 2594 | dec20( 2595 | dict, 2596 | ) 2597 | >>= ( 2598 | v20 => 2599 | dec21( 2600 | dict, 2601 | ) 2602 | >>= ( 2603 | v21 => 2604 | dec22( 2605 | dict, 2606 | ) 2607 | >>= ( 2608 | v22 => 2609 | dec23( 2610 | dict, 2611 | ) 2612 | >>= ( 2613 | v23 => 2614 | Belt.Result.Ok(( 2615 | v1, 2616 | v2, 2617 | v3, 2618 | v4, 2619 | v5, 2620 | v6, 2621 | v7, 2622 | v8, 2623 | v9, 2624 | v10, 2625 | v11, 2626 | v12, 2627 | v13, 2628 | v14, 2629 | v15, 2630 | v16, 2631 | v17, 2632 | v18, 2633 | v19, 2634 | v20, 2635 | v21, 2636 | v22, 2637 | v23, 2638 | )) 2639 | ) 2640 | ) 2641 | ) 2642 | ) 2643 | ) 2644 | ) 2645 | ) 2646 | ) 2647 | ) 2648 | ) 2649 | ) 2650 | ) 2651 | ) 2652 | ) 2653 | ) 2654 | ) 2655 | ) 2656 | ) 2657 | ) 2658 | ) 2659 | ) 2660 | ) 2661 | ) 2662 | ); 2663 | (encode, decode); 2664 | }; 2665 | let object24 = 2666 | ( 2667 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 2668 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 2669 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 2670 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 2671 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 2672 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 2673 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 2674 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 2675 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 2676 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 2677 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 2678 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 2679 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 2680 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 2681 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 2682 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 2683 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 2684 | (enc18, dec18): JsonCodec_core.FieldCodec.t('r), 2685 | (enc19, dec19): JsonCodec_core.FieldCodec.t('s), 2686 | (enc20, dec20): JsonCodec_core.FieldCodec.t('t), 2687 | (enc21, dec21): JsonCodec_core.FieldCodec.t('u), 2688 | (enc22, dec22): JsonCodec_core.FieldCodec.t('v), 2689 | (enc23, dec23): JsonCodec_core.FieldCodec.t('w), 2690 | (enc24, dec24): JsonCodec_core.FieldCodec.t('x), 2691 | ) 2692 | : JsonCodec_core.Codec.t( 2693 | ( 2694 | 'a, 2695 | 'b, 2696 | 'c, 2697 | 'd, 2698 | 'e, 2699 | 'f, 2700 | 'g, 2701 | 'h, 2702 | 'i, 2703 | 'j, 2704 | 'k, 2705 | 'l, 2706 | 'm, 2707 | 'n, 2708 | 'o, 2709 | 'p, 2710 | 'q, 2711 | 'r, 2712 | 's, 2713 | 't, 2714 | 'u, 2715 | 'v, 2716 | 'w, 2717 | 'x, 2718 | ), 2719 | ) => { 2720 | let encode = 2721 | ( 2722 | ( 2723 | v1, 2724 | v2, 2725 | v3, 2726 | v4, 2727 | v5, 2728 | v6, 2729 | v7, 2730 | v8, 2731 | v9, 2732 | v10, 2733 | v11, 2734 | v12, 2735 | v13, 2736 | v14, 2737 | v15, 2738 | v16, 2739 | v17, 2740 | v18, 2741 | v19, 2742 | v20, 2743 | v21, 2744 | v22, 2745 | v23, 2746 | v24, 2747 | ), 2748 | ) => 2749 | Js.Json.object_ @@ 2750 | JsonCodec_util.buildDict([ 2751 | enc1(v1), 2752 | enc2(v2), 2753 | enc3(v3), 2754 | enc4(v4), 2755 | enc5(v5), 2756 | enc6(v6), 2757 | enc7(v7), 2758 | enc8(v8), 2759 | enc9(v9), 2760 | enc10(v10), 2761 | enc11(v11), 2762 | enc12(v12), 2763 | enc13(v13), 2764 | enc14(v14), 2765 | enc15(v15), 2766 | enc16(v16), 2767 | enc17(v17), 2768 | enc18(v18), 2769 | enc19(v19), 2770 | enc20(v20), 2771 | enc21(v21), 2772 | enc22(v22), 2773 | enc23(v23), 2774 | enc24(v24), 2775 | ]); 2776 | let decode = json => 2777 | JsonCodec_util.decodeRawObject(json) 2778 | >>= ( 2779 | dict => 2780 | dec1(dict) 2781 | >>= ( 2782 | v1 => 2783 | dec2(dict) 2784 | >>= ( 2785 | v2 => 2786 | dec3(dict) 2787 | >>= ( 2788 | v3 => 2789 | dec4(dict) 2790 | >>= ( 2791 | v4 => 2792 | dec5(dict) 2793 | >>= ( 2794 | v5 => 2795 | dec6(dict) 2796 | >>= ( 2797 | v6 => 2798 | dec7(dict) 2799 | >>= ( 2800 | v7 => 2801 | dec8(dict) 2802 | >>= ( 2803 | v8 => 2804 | dec9(dict) 2805 | >>= ( 2806 | v9 => 2807 | dec10(dict) 2808 | >>= ( 2809 | v10 => 2810 | dec11(dict) 2811 | >>= ( 2812 | v11 => 2813 | dec12(dict) 2814 | >>= ( 2815 | v12 => 2816 | dec13(dict) 2817 | >>= ( 2818 | v13 => 2819 | dec14(dict) 2820 | >>= ( 2821 | v14 => 2822 | dec15(dict) 2823 | >>= ( 2824 | v15 => 2825 | dec16( 2826 | dict, 2827 | ) 2828 | >>= ( 2829 | v16 => 2830 | dec17( 2831 | dict, 2832 | ) 2833 | >>= ( 2834 | v17 => 2835 | dec18( 2836 | dict, 2837 | ) 2838 | >>= ( 2839 | v18 => 2840 | dec19( 2841 | dict, 2842 | ) 2843 | >>= ( 2844 | v19 => 2845 | dec20( 2846 | dict, 2847 | ) 2848 | >>= ( 2849 | v20 => 2850 | dec21( 2851 | dict, 2852 | ) 2853 | >>= ( 2854 | v21 => 2855 | dec22( 2856 | dict, 2857 | ) 2858 | >>= ( 2859 | v22 => 2860 | dec23( 2861 | dict, 2862 | ) 2863 | >>= ( 2864 | v23 => 2865 | dec24( 2866 | dict, 2867 | ) 2868 | >>= ( 2869 | v24 => 2870 | Belt.Result.Ok(( 2871 | v1, 2872 | v2, 2873 | v3, 2874 | v4, 2875 | v5, 2876 | v6, 2877 | v7, 2878 | v8, 2879 | v9, 2880 | v10, 2881 | v11, 2882 | v12, 2883 | v13, 2884 | v14, 2885 | v15, 2886 | v16, 2887 | v17, 2888 | v18, 2889 | v19, 2890 | v20, 2891 | v21, 2892 | v22, 2893 | v23, 2894 | v24, 2895 | )) 2896 | ) 2897 | ) 2898 | ) 2899 | ) 2900 | ) 2901 | ) 2902 | ) 2903 | ) 2904 | ) 2905 | ) 2906 | ) 2907 | ) 2908 | ) 2909 | ) 2910 | ) 2911 | ) 2912 | ) 2913 | ) 2914 | ) 2915 | ) 2916 | ) 2917 | ) 2918 | ) 2919 | ) 2920 | ); 2921 | (encode, decode); 2922 | }; 2923 | let object25 = 2924 | ( 2925 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 2926 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 2927 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 2928 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 2929 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 2930 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 2931 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 2932 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 2933 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 2934 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 2935 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 2936 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 2937 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 2938 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 2939 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 2940 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 2941 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 2942 | (enc18, dec18): JsonCodec_core.FieldCodec.t('r), 2943 | (enc19, dec19): JsonCodec_core.FieldCodec.t('s), 2944 | (enc20, dec20): JsonCodec_core.FieldCodec.t('t), 2945 | (enc21, dec21): JsonCodec_core.FieldCodec.t('u), 2946 | (enc22, dec22): JsonCodec_core.FieldCodec.t('v), 2947 | (enc23, dec23): JsonCodec_core.FieldCodec.t('w), 2948 | (enc24, dec24): JsonCodec_core.FieldCodec.t('x), 2949 | (enc25, dec25): JsonCodec_core.FieldCodec.t('y), 2950 | ) 2951 | : JsonCodec_core.Codec.t( 2952 | ( 2953 | 'a, 2954 | 'b, 2955 | 'c, 2956 | 'd, 2957 | 'e, 2958 | 'f, 2959 | 'g, 2960 | 'h, 2961 | 'i, 2962 | 'j, 2963 | 'k, 2964 | 'l, 2965 | 'm, 2966 | 'n, 2967 | 'o, 2968 | 'p, 2969 | 'q, 2970 | 'r, 2971 | 's, 2972 | 't, 2973 | 'u, 2974 | 'v, 2975 | 'w, 2976 | 'x, 2977 | 'y, 2978 | ), 2979 | ) => { 2980 | let encode = 2981 | ( 2982 | ( 2983 | v1, 2984 | v2, 2985 | v3, 2986 | v4, 2987 | v5, 2988 | v6, 2989 | v7, 2990 | v8, 2991 | v9, 2992 | v10, 2993 | v11, 2994 | v12, 2995 | v13, 2996 | v14, 2997 | v15, 2998 | v16, 2999 | v17, 3000 | v18, 3001 | v19, 3002 | v20, 3003 | v21, 3004 | v22, 3005 | v23, 3006 | v24, 3007 | v25, 3008 | ), 3009 | ) => 3010 | Js.Json.object_ @@ 3011 | JsonCodec_util.buildDict([ 3012 | enc1(v1), 3013 | enc2(v2), 3014 | enc3(v3), 3015 | enc4(v4), 3016 | enc5(v5), 3017 | enc6(v6), 3018 | enc7(v7), 3019 | enc8(v8), 3020 | enc9(v9), 3021 | enc10(v10), 3022 | enc11(v11), 3023 | enc12(v12), 3024 | enc13(v13), 3025 | enc14(v14), 3026 | enc15(v15), 3027 | enc16(v16), 3028 | enc17(v17), 3029 | enc18(v18), 3030 | enc19(v19), 3031 | enc20(v20), 3032 | enc21(v21), 3033 | enc22(v22), 3034 | enc23(v23), 3035 | enc24(v24), 3036 | enc25(v25), 3037 | ]); 3038 | let decode = json => 3039 | JsonCodec_util.decodeRawObject(json) 3040 | >>= ( 3041 | dict => 3042 | dec1(dict) 3043 | >>= ( 3044 | v1 => 3045 | dec2(dict) 3046 | >>= ( 3047 | v2 => 3048 | dec3(dict) 3049 | >>= ( 3050 | v3 => 3051 | dec4(dict) 3052 | >>= ( 3053 | v4 => 3054 | dec5(dict) 3055 | >>= ( 3056 | v5 => 3057 | dec6(dict) 3058 | >>= ( 3059 | v6 => 3060 | dec7(dict) 3061 | >>= ( 3062 | v7 => 3063 | dec8(dict) 3064 | >>= ( 3065 | v8 => 3066 | dec9(dict) 3067 | >>= ( 3068 | v9 => 3069 | dec10(dict) 3070 | >>= ( 3071 | v10 => 3072 | dec11(dict) 3073 | >>= ( 3074 | v11 => 3075 | dec12(dict) 3076 | >>= ( 3077 | v12 => 3078 | dec13(dict) 3079 | >>= ( 3080 | v13 => 3081 | dec14(dict) 3082 | >>= ( 3083 | v14 => 3084 | dec15(dict) 3085 | >>= ( 3086 | v15 => 3087 | dec16( 3088 | dict, 3089 | ) 3090 | >>= ( 3091 | v16 => 3092 | dec17( 3093 | dict, 3094 | ) 3095 | >>= ( 3096 | v17 => 3097 | dec18( 3098 | dict, 3099 | ) 3100 | >>= ( 3101 | v18 => 3102 | dec19( 3103 | dict, 3104 | ) 3105 | >>= ( 3106 | v19 => 3107 | dec20( 3108 | dict, 3109 | ) 3110 | >>= ( 3111 | v20 => 3112 | dec21( 3113 | dict, 3114 | ) 3115 | >>= ( 3116 | v21 => 3117 | dec22( 3118 | dict, 3119 | ) 3120 | >>= ( 3121 | v22 => 3122 | dec23( 3123 | dict, 3124 | ) 3125 | >>= ( 3126 | v23 => 3127 | dec24( 3128 | dict, 3129 | ) 3130 | >>= ( 3131 | v24 => 3132 | dec25( 3133 | dict, 3134 | ) 3135 | >>= ( 3136 | v25 => 3137 | Belt.Result.Ok(( 3138 | v1, 3139 | v2, 3140 | v3, 3141 | v4, 3142 | v5, 3143 | v6, 3144 | v7, 3145 | v8, 3146 | v9, 3147 | v10, 3148 | v11, 3149 | v12, 3150 | v13, 3151 | v14, 3152 | v15, 3153 | v16, 3154 | v17, 3155 | v18, 3156 | v19, 3157 | v20, 3158 | v21, 3159 | v22, 3160 | v23, 3161 | v24, 3162 | v25, 3163 | )) 3164 | ) 3165 | ) 3166 | ) 3167 | ) 3168 | ) 3169 | ) 3170 | ) 3171 | ) 3172 | ) 3173 | ) 3174 | ) 3175 | ) 3176 | ) 3177 | ) 3178 | ) 3179 | ) 3180 | ) 3181 | ) 3182 | ) 3183 | ) 3184 | ) 3185 | ) 3186 | ) 3187 | ) 3188 | ) 3189 | ); 3190 | (encode, decode); 3191 | }; 3192 | let object26 = 3193 | ( 3194 | (enc1, dec1): JsonCodec_core.FieldCodec.t('a), 3195 | (enc2, dec2): JsonCodec_core.FieldCodec.t('b), 3196 | (enc3, dec3): JsonCodec_core.FieldCodec.t('c), 3197 | (enc4, dec4): JsonCodec_core.FieldCodec.t('d), 3198 | (enc5, dec5): JsonCodec_core.FieldCodec.t('e), 3199 | (enc6, dec6): JsonCodec_core.FieldCodec.t('f), 3200 | (enc7, dec7): JsonCodec_core.FieldCodec.t('g), 3201 | (enc8, dec8): JsonCodec_core.FieldCodec.t('h), 3202 | (enc9, dec9): JsonCodec_core.FieldCodec.t('i), 3203 | (enc10, dec10): JsonCodec_core.FieldCodec.t('j), 3204 | (enc11, dec11): JsonCodec_core.FieldCodec.t('k), 3205 | (enc12, dec12): JsonCodec_core.FieldCodec.t('l), 3206 | (enc13, dec13): JsonCodec_core.FieldCodec.t('m), 3207 | (enc14, dec14): JsonCodec_core.FieldCodec.t('n), 3208 | (enc15, dec15): JsonCodec_core.FieldCodec.t('o), 3209 | (enc16, dec16): JsonCodec_core.FieldCodec.t('p), 3210 | (enc17, dec17): JsonCodec_core.FieldCodec.t('q), 3211 | (enc18, dec18): JsonCodec_core.FieldCodec.t('r), 3212 | (enc19, dec19): JsonCodec_core.FieldCodec.t('s), 3213 | (enc20, dec20): JsonCodec_core.FieldCodec.t('t), 3214 | (enc21, dec21): JsonCodec_core.FieldCodec.t('u), 3215 | (enc22, dec22): JsonCodec_core.FieldCodec.t('v), 3216 | (enc23, dec23): JsonCodec_core.FieldCodec.t('w), 3217 | (enc24, dec24): JsonCodec_core.FieldCodec.t('x), 3218 | (enc25, dec25): JsonCodec_core.FieldCodec.t('y), 3219 | (enc26, dec26): JsonCodec_core.FieldCodec.t('z), 3220 | ) 3221 | : JsonCodec_core.Codec.t( 3222 | ( 3223 | 'a, 3224 | 'b, 3225 | 'c, 3226 | 'd, 3227 | 'e, 3228 | 'f, 3229 | 'g, 3230 | 'h, 3231 | 'i, 3232 | 'j, 3233 | 'k, 3234 | 'l, 3235 | 'm, 3236 | 'n, 3237 | 'o, 3238 | 'p, 3239 | 'q, 3240 | 'r, 3241 | 's, 3242 | 't, 3243 | 'u, 3244 | 'v, 3245 | 'w, 3246 | 'x, 3247 | 'y, 3248 | 'z, 3249 | ), 3250 | ) => { 3251 | let encode = 3252 | ( 3253 | ( 3254 | v1, 3255 | v2, 3256 | v3, 3257 | v4, 3258 | v5, 3259 | v6, 3260 | v7, 3261 | v8, 3262 | v9, 3263 | v10, 3264 | v11, 3265 | v12, 3266 | v13, 3267 | v14, 3268 | v15, 3269 | v16, 3270 | v17, 3271 | v18, 3272 | v19, 3273 | v20, 3274 | v21, 3275 | v22, 3276 | v23, 3277 | v24, 3278 | v25, 3279 | v26, 3280 | ), 3281 | ) => 3282 | Js.Json.object_ @@ 3283 | JsonCodec_util.buildDict([ 3284 | enc1(v1), 3285 | enc2(v2), 3286 | enc3(v3), 3287 | enc4(v4), 3288 | enc5(v5), 3289 | enc6(v6), 3290 | enc7(v7), 3291 | enc8(v8), 3292 | enc9(v9), 3293 | enc10(v10), 3294 | enc11(v11), 3295 | enc12(v12), 3296 | enc13(v13), 3297 | enc14(v14), 3298 | enc15(v15), 3299 | enc16(v16), 3300 | enc17(v17), 3301 | enc18(v18), 3302 | enc19(v19), 3303 | enc20(v20), 3304 | enc21(v21), 3305 | enc22(v22), 3306 | enc23(v23), 3307 | enc24(v24), 3308 | enc25(v25), 3309 | enc26(v26), 3310 | ]); 3311 | let decode = json => 3312 | JsonCodec_util.decodeRawObject(json) 3313 | >>= ( 3314 | dict => 3315 | dec1(dict) 3316 | >>= ( 3317 | v1 => 3318 | dec2(dict) 3319 | >>= ( 3320 | v2 => 3321 | dec3(dict) 3322 | >>= ( 3323 | v3 => 3324 | dec4(dict) 3325 | >>= ( 3326 | v4 => 3327 | dec5(dict) 3328 | >>= ( 3329 | v5 => 3330 | dec6(dict) 3331 | >>= ( 3332 | v6 => 3333 | dec7(dict) 3334 | >>= ( 3335 | v7 => 3336 | dec8(dict) 3337 | >>= ( 3338 | v8 => 3339 | dec9(dict) 3340 | >>= ( 3341 | v9 => 3342 | dec10(dict) 3343 | >>= ( 3344 | v10 => 3345 | dec11(dict) 3346 | >>= ( 3347 | v11 => 3348 | dec12(dict) 3349 | >>= ( 3350 | v12 => 3351 | dec13(dict) 3352 | >>= ( 3353 | v13 => 3354 | dec14(dict) 3355 | >>= ( 3356 | v14 => 3357 | dec15(dict) 3358 | >>= ( 3359 | v15 => 3360 | dec16( 3361 | dict, 3362 | ) 3363 | >>= ( 3364 | v16 => 3365 | dec17( 3366 | dict, 3367 | ) 3368 | >>= ( 3369 | v17 => 3370 | dec18( 3371 | dict, 3372 | ) 3373 | >>= ( 3374 | v18 => 3375 | dec19( 3376 | dict, 3377 | ) 3378 | >>= ( 3379 | v19 => 3380 | dec20( 3381 | dict, 3382 | ) 3383 | >>= ( 3384 | v20 => 3385 | dec21( 3386 | dict, 3387 | ) 3388 | >>= ( 3389 | v21 => 3390 | dec22( 3391 | dict, 3392 | ) 3393 | >>= ( 3394 | v22 => 3395 | dec23( 3396 | dict, 3397 | ) 3398 | >>= ( 3399 | v23 => 3400 | dec24( 3401 | dict, 3402 | ) 3403 | >>= ( 3404 | v24 => 3405 | dec25( 3406 | dict, 3407 | ) 3408 | >>= ( 3409 | v25 => 3410 | dec26( 3411 | dict, 3412 | ) 3413 | >>= ( 3414 | v26 => 3415 | Belt.Result.Ok(( 3416 | v1, 3417 | v2, 3418 | v3, 3419 | v4, 3420 | v5, 3421 | v6, 3422 | v7, 3423 | v8, 3424 | v9, 3425 | v10, 3426 | v11, 3427 | v12, 3428 | v13, 3429 | v14, 3430 | v15, 3431 | v16, 3432 | v17, 3433 | v18, 3434 | v19, 3435 | v20, 3436 | v21, 3437 | v22, 3438 | v23, 3439 | v24, 3440 | v25, 3441 | v26, 3442 | )) 3443 | ) 3444 | ) 3445 | ) 3446 | ) 3447 | ) 3448 | ) 3449 | ) 3450 | ) 3451 | ) 3452 | ) 3453 | ) 3454 | ) 3455 | ) 3456 | ) 3457 | ) 3458 | ) 3459 | ) 3460 | ) 3461 | ) 3462 | ) 3463 | ) 3464 | ) 3465 | ) 3466 | ) 3467 | ) 3468 | ) 3469 | ); 3470 | (encode, decode); 3471 | }; 3472 | --------------------------------------------------------------------------------