@kaiko.io/rescript-deser 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bsconfig.json +4 -0
- package/package.json +6 -1
- package/src/JSON.res +1 -22
- package/tests/compile.res +22 -0
- package/.tern-port +0 -1
package/README.md
CHANGED
package/bsconfig.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaiko.io/rescript-deser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"json",
|
|
6
|
+
"deserializer",
|
|
7
|
+
"rescript"
|
|
8
|
+
],
|
|
4
9
|
"description": "Simple JSON deserializer for ReScript",
|
|
5
10
|
"repository": "https://gitlab.com/kaiko-systems/rescript-deser",
|
|
6
11
|
"author": "Kaiko Systems <info@kaikosystems.com>",
|
package/src/JSON.res
CHANGED
|
@@ -253,7 +253,7 @@ module type Serializable = {
|
|
|
253
253
|
let fields: Field.t
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
module
|
|
256
|
+
module MakeDeserializer = (S: Serializable): (Deserializer with type t = S.t) => {
|
|
257
257
|
type t = S.t
|
|
258
258
|
let fields = S.fields
|
|
259
259
|
%%private(let (loc, _f) = __LOC_OF__(module(S: Serializable)))
|
|
@@ -269,24 +269,3 @@ module Deserializer = (S: Serializable) => {
|
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
|
|
273
|
-
module Test = {
|
|
274
|
-
type appointment = {
|
|
275
|
-
note: string,
|
|
276
|
-
date: Js.Date.t,
|
|
277
|
-
}
|
|
278
|
-
module Appointment = Deserializer({
|
|
279
|
-
type t = appointment
|
|
280
|
-
open Field
|
|
281
|
-
|
|
282
|
-
let fields = Object([("note", String), ("date", Date)])
|
|
283
|
-
})
|
|
284
|
-
|
|
285
|
-
type foo = array<appointment>
|
|
286
|
-
module Foo = Deserializer({
|
|
287
|
-
type t = foo
|
|
288
|
-
open Field
|
|
289
|
-
|
|
290
|
-
let fields = DefaultWhenInvalid(Array(Deserializer(module(Appointment))), []->FieldValue.array)
|
|
291
|
-
})
|
|
292
|
-
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
open JSON
|
|
2
|
+
|
|
3
|
+
module Test = {
|
|
4
|
+
type appointment = {
|
|
5
|
+
note: string,
|
|
6
|
+
date: Js.Date.t,
|
|
7
|
+
}
|
|
8
|
+
module Appointment = MakeDeserializer({
|
|
9
|
+
type t = appointment
|
|
10
|
+
open JSON.Field
|
|
11
|
+
|
|
12
|
+
let fields = Object([("note", String), ("date", Date)])
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
type foo = array<appointment>
|
|
16
|
+
module Foo = MakeDeserializer({
|
|
17
|
+
type t = foo
|
|
18
|
+
open JSON.Field
|
|
19
|
+
|
|
20
|
+
let fields = DefaultWhenInvalid(Array(Deserializer(module(Appointment))), []->FieldValue.array)
|
|
21
|
+
})
|
|
22
|
+
}
|
package/.tern-port
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
40513
|