Skip to content

Commit df8647b

Browse files
authored
Merge pull request #1410 from informalsystems/gabriela/serialize-sets
Fix serialization of Sets
2 parents 60ed3ba + 9557b01 commit df8647b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Removed a dependency causing deprecation errors messages to be emitted.
3333
(#1380)
3434
- Fixed a type checker bug causing too general types to be inferred (#1409).
35+
- Fixes serialization of Sets in JSON outputs (#1410).
3536

3637
### Security
3738

quint/src/cliCommands.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ function addItfHeader(source: string, status: string, traceInJson: any): any {
901901

902902
// Preprocess troublesome types so they are represented in JSON.
903903
//
904-
// We need it particularly because, by default, serialization of Map
904+
// We need it particularly because, by default, serialization of Map and Set
905905
// objects just produces an empty object
906906
// (see https://stackoverflow.com/questions/46634449/json-stringify-of-object-of-map-return-empty)
907907
//
@@ -910,6 +910,9 @@ function replacer(_key: String, value: any): any {
910910
if (value instanceof Map) {
911911
// Represent Maps as JSON objects
912912
return Object.fromEntries(value)
913+
} else if (value instanceof Set) {
914+
// Represent Sets as JSON arrays
915+
return Array.from(value)
913916
} else {
914917
return value
915918
}

0 commit comments

Comments
 (0)