Skip to content

Commit 11df977

Browse files
committed
Format + changelog
1 parent 23f5f7f commit 11df977

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Runtime: refactor caml_xmlhttprequest_create implementation (#1846)
1010
* Runtime: update constant imports to use `node:fs` module (#1850)
1111
* Runtime: make Obj.dup work with floats and boxed numbers (#1871)
12+
* Lib: make the Wasm version of Json.output work with native ints and JavaScript objects (#1872)
1213

1314
## Bug fixes
1415
* Runtime: fix path normalization (#1848)

lib/js_of_ocaml/json.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ let rec write b v =
116116
write_int64 b i
117117
| id -> failwith (Printf.sprintf "Json.output: unsupported custom value %s " id)
118118
else if t = Obj.abstract_tag
119-
then
120-
(* Presumably a JavaScript value *)
121-
Buffer.add_string b (Js.to_string (json##stringify v))
119+
then
120+
(* Presumably a JavaScript value *)
121+
Buffer.add_string b (Js.to_string (json##stringify v))
122122
else failwith (Printf.sprintf "Json.output: unsupported tag %d " t)
123123

124124
let to_json v =

lib/tests/test_json.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ let%expect_test _ =
6363
[%expect {| 2 |}]
6464

6565
let%expect_test "JavaScript object" =
66-
let x = object%js val x = 1 val y = Js.string "abcd" end in
66+
let x =
67+
object%js
68+
val x = 1
69+
70+
val y = Js.string "abcd"
71+
end
72+
in
6773
let s = Json.output x in
6874
let s1 = Js.to_string s in
6975
Printf.printf "%s\n" s1;

0 commit comments

Comments
 (0)