@@ -44,6 +44,7 @@ type rec t = Stdlib_JSON.t =
44
44
| Object (dict <t >)
45
45
| Array (array <t >)
46
46
47
+ @deprecated ("This functionality has been deprecated and will be removed in v13." )
47
48
module Kind : {
48
49
type json = t
49
50
/** Underlying type of a JSON value */
@@ -56,6 +57,7 @@ module Kind: {
56
57
| Null : t <Js_types .null_val >
57
58
}
58
59
60
+ @deprecated ("This functionality has been deprecated and will be removed in v13." )
59
61
type tagged_t =
60
62
| JSONFalse
61
63
| JSONTrue
@@ -67,48 +69,67 @@ type tagged_t =
67
69
68
70
/* ## Accessors */
69
71
72
+ @deprecated ("This functionality has been deprecated and will be removed in v13." )
70
73
let classify : t => tagged_t
71
74
72
75
/**
73
76
`test(v, kind)` returns `true` if `v` is of `kind`.
74
77
*/
78
+ @deprecated ("This functionality has been deprecated and will be removed in v13." )
75
79
let test : ('a , Kind .t <'b >) => bool
76
80
77
81
/**
78
82
`decodeString(json)` returns `Some(s)` if `json` is a `string`, `None` otherwise.
79
83
*/
80
84
@deprecated ({
81
- reason : "Use pattern matching instead." ,
82
- migrate : switch %insert.unlabelledArgument (0 ) {
83
- | JSON .String (str ) => Some (str )
84
- | _ => None
85
- },
85
+ reason : "Use `JSON.Decode.string` instead." ,
86
+ migrate : JSON .Decode .string (),
86
87
})
87
88
let decodeString : t => option <Js_string .t >
88
89
89
90
/**
90
91
`decodeNumber(json)` returns `Some(n)` if `json` is a `number`, `None` otherwise.
91
92
*/
93
+ @deprecated ({
94
+ reason : "Use `JSON.Decode.float` instead." ,
95
+ migrate : JSON .Decode .float (),
96
+ })
92
97
let decodeNumber : t => option <float >
93
98
94
99
/**
95
100
`decodeObject(json)` returns `Some(o)` if `json` is an `object`, `None` otherwise.
96
101
*/
102
+ @deprecated ({
103
+ reason : "Use `JSON.Decode.object` instead." ,
104
+ migrate : JSON .Decode .object (),
105
+ })
97
106
let decodeObject : t => option <dict <t >>
98
107
99
108
/**
100
109
`decodeArray(json)` returns `Some(a)` if `json` is an `array`, `None` otherwise.
101
110
*/
111
+ @deprecated ({
112
+ reason : "Use `JSON.Decode.array` instead." ,
113
+ migrate : JSON .Decode .array (),
114
+ })
102
115
let decodeArray : t => option <array <t >>
103
116
104
117
/**
105
118
`decodeBoolean(json)` returns `Some(b)` if `json` is a `boolean`, `None` otherwise.
106
119
*/
120
+ @deprecated ({
121
+ reason : "Use `JSON.Decode.bool` instead." ,
122
+ migrate : JSON .Decode .bool (),
123
+ })
107
124
let decodeBoolean : t => option <bool >
108
125
109
126
/**
110
127
`decodeNull(json)` returns `Some(null)` if `json` is a `null`, `None` otherwise.
111
128
*/
129
+ @deprecated ({
130
+ reason : "Use JSON.Decode.null instead." ,
131
+ migrate : JSON .Decode .null (),
132
+ })
112
133
let decodeNull : t => option <Js_null .t <'a >>
113
134
114
135
/* ## Constructors */
@@ -119,22 +140,46 @@ let decodeNull: t => option<Js_null.t<'a>>
119
140
*/
120
141
121
142
/** `null` is the singleton null JSON value. */
143
+ @deprecated ({
144
+ reason : "Use `JSON.Encode.null` instead." ,
145
+ migrate : JSON .Encode .null ,
146
+ })
122
147
@val
123
148
external null : t = "null"
124
149
125
150
/** `string(s)` makes a JSON string of the `string` `s`. */
151
+ @deprecated ({
152
+ reason : "Use `JSON.Encode.string` instead." ,
153
+ migrate : JSON .Encode .string (),
154
+ })
126
155
external string : string => t = "%identity"
127
156
128
157
/** `number(n)` makes a JSON number of the `float` `n`. */
158
+ @deprecated ({
159
+ reason : "Use `JSON.Encode.float` instead." ,
160
+ migrate : JSON .Encode .float (),
161
+ })
129
162
external number : float => t = "%identity"
130
163
131
164
/** `boolean(b)` makes a JSON boolean of the `bool` `b`. */
165
+ @deprecated ({
166
+ reason : "Use `JSON.Encode.bool` instead." ,
167
+ migrate : JSON .Encode .bool (),
168
+ })
132
169
external boolean : bool => t = "%identity"
133
170
134
171
/** `object_(dict)` makes a JSON object of the `dict`. */
172
+ @deprecated ({
173
+ reason : "Use `JSON.Encode.object` instead." ,
174
+ migrate : JSON .Encode .object (),
175
+ })
135
176
external object_ : dict <t > => t = "%identity"
136
177
137
178
/** `array_(a)` makes a JSON array of the `Js.Json.t` array `a`. */
179
+ @deprecated ({
180
+ reason : "Use `JSON.Encode.array` instead." ,
181
+ migrate : JSON .Encode .array (),
182
+ })
138
183
external array : array <t > => t = "%identity"
139
184
140
185
/*
@@ -144,15 +189,31 @@ external array: array<t> => t = "%identity"
144
189
*/
145
190
146
191
/** `stringArray(a)` makes a JSON array of the `string` array `a`. */
192
+ @deprecated ({
193
+ reason : "Use `JSON.Encode.stringArray` instead." ,
194
+ migrate : JSON .Encode .stringArray (),
195
+ })
147
196
external stringArray : array <string > => t = "%identity"
148
197
149
198
/** `numberArray(a)` makes a JSON array of the `float` array `a`. */
199
+ @deprecated ({
200
+ reason : "Use `JSON.Encode.floatArray` instead." ,
201
+ migrate : JSON .Encode .floatArray (),
202
+ })
150
203
external numberArray : array <float > => t = "%identity"
151
204
152
205
/** `booleanArray(a)` makes a JSON array of the `bool` array `a`. */
206
+ @deprecated ({
207
+ reason : "Use `JSON.Encode.boolArray` instead." ,
208
+ migrate : JSON .Encode .boolArray (),
209
+ })
153
210
external booleanArray : array <bool > => t = "%identity"
154
211
155
212
/** `objectArray(a) makes a JSON array of the `JsDict.t` array `a`. */
213
+ @deprecated ({
214
+ reason : "Use `JSON.Encode.objectArray` instead." ,
215
+ migrate : JSON .Encode .objectArray (),
216
+ })
156
217
external objectArray : array <dict <t >> => t = "%identity"
157
218
158
219
/* ## String conversion */
@@ -207,7 +268,12 @@ let getIds = s => {
207
268
Js.log(getIds(` { "ids" : [1, 2, 3 ] } `))
208
269
```
209
270
*/
210
- @val @scope ("JSON" )
271
+ @deprecated ({
272
+ reason : "Use `JSON.parseOrThrow` instead." ,
273
+ migrate : JSON .parseOrThrow (),
274
+ })
275
+ @val
276
+ @scope ("JSON" )
211
277
external parseExn : string => t = "parse"
212
278
213
279
/**
@@ -229,7 +295,12 @@ Js.Dict.set(dict, "likes", Js.Json.stringArray(["ReScript", "ocaml", "js"]))
229
295
Js.log(Js.Json.stringify(Js.Json.object_(dict)))
230
296
```
231
297
*/
232
- @val @scope ("JSON" )
298
+ @deprecated ({
299
+ reason : "Use `JSON.stringify` instead." ,
300
+ migrate : JSON .stringify (),
301
+ })
302
+ @val
303
+ @scope ("JSON" )
233
304
external stringify : t => string = "stringify"
234
305
235
306
/**
@@ -251,7 +322,12 @@ Js.Dict.set(dict, "likes", Js.Json.stringArray(["ReScript", "ocaml", "js"]))
251
322
Js.log(Js.Json.stringifyWithSpace(Js.Json.object_(dict), 2))
252
323
```
253
324
*/
254
- @val @scope ("JSON" )
325
+ @deprecated ({
326
+ reason : "Use `JSON.stringify` with optional `~space` instead." ,
327
+ migrate : JSON .stringify (~space = %insert.unlabelledArgument (2 )),
328
+ })
329
+ @val
330
+ @scope ("JSON" )
255
331
external stringifyWithSpace : (t , @as (json ` null` ) _ , int ) => string = "stringify"
256
332
257
333
/**
@@ -264,7 +340,12 @@ external stringifyWithSpace: (t, @as(json`null`) _, int) => string = "stringify"
264
340
Js.log(Js.Json.stringifyAny(["hello", "world"]))
265
341
```
266
342
*/
267
- @val @scope ("JSON" )
343
+ @deprecated ({
344
+ reason : "Use `JSON.stringifyAny` instead." ,
345
+ migrate : JSON .stringifyAny (),
346
+ })
347
+ @val
348
+ @scope ("JSON" )
268
349
external stringifyAny : 'a => option <string > = "stringify"
269
350
270
351
/**
@@ -275,6 +356,7 @@ It is unsafe in two aspects
275
356
- It may throw during parsing
276
357
- when you cast it to a specific type, it may have a type mismatch
277
358
*/
359
+ @deprecated ("This functionality has been deprecated and will be removed in v13." )
278
360
let deserializeUnsafe : string => 'a
279
361
280
362
/**
@@ -283,4 +365,5 @@ It will raise in such situations:
283
365
- There are cycles
284
366
- Some JS engines can not stringify deeply nested json objects
285
367
*/
368
+ @deprecated ("This functionality has been deprecated and will be removed in v13." )
286
369
let serializeExn : 'a => string
0 commit comments