File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -127,3 +127,5 @@ external booleanArray : Js.boolean array -> t = "%identity"
127127external objectArray : t Js_dict .t array -> t = " %identity"
128128external stringify : t -> string = " stringify"
129129 [@@ bs.val] [@@ bs.scope "JSON" ]
130+ external stringifyWithSpace : t -> (_ [@ bs.as {json| null| json}]) -> int -> string = " stringify"
131+ [@@ bs.val] [@@ bs.scope "JSON" ]
Original file line number Diff line number Diff line change @@ -201,6 +201,28 @@ Js.log \@\@ Js.Json.stringify (Js.Json.object_ dict)
201201@see <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify> MDN
202202*)
203203
204+ external stringifyWithSpace : t -> (_ [@ bs.as {json| null| json}]) -> int -> string = " stringify"
205+ [@@ bs.val] [@@ bs.scope "JSON" ]
206+ (* * [stringify json] formats the JSON data structure as a string
207+
208+ {b Returns} the string representation of a given JSON data structure
209+
210+ @example {[
211+ (* Creates and stringifies a simple JS object with spacing *)
212+
213+ let dict = Js.Dict.empty () in
214+ Js.Dict.set dict "name" (Js.Json.string "John Doe");
215+ Js.Dict.set dict "age" (Js.Json.numberOfInt 30);
216+ Js.Dict.set dict "likes"
217+ (Js.Json.stringArray [|"bucklescript";"ocaml";"js"|]);
218+
219+ Js.log \@\@ Js.Json.stringify (Js.Json.object_ dict) 2
220+ ]}
221+
222+ @see <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify> MDN
223+ *)
224+
225+
204226external stringifyAny : 'a -> string option = " stringify"
205227 [@@ bs.val] [@@ bs.return undefined_to_opt ] [@@ bs.scope "JSON" ]
206228(* * [stringifyAny value] formats any [value] into a JSON string
You can’t perform that action at this time.
0 commit comments