Skip to content

Commit 4ac2967

Browse files
committed
fix: correct JSON format for decimal number inside object in mongo
1 parent 9998423 commit 4ac2967

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

adminforth/dataConnectors/mongo.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,17 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
213213
return null;
214214
}
215215
return value?.toString();
216+
} else if (field.type == AdminForthDataTypes.JSON) {
217+
if (JSON.stringify(value).includes('$numberDecimal')) {
218+
const json = JSON.stringify(value, (key, value) => {
219+
if (value && typeof value === 'object' && '$numberDecimal' in value) {
220+
return value.$numberDecimal;
221+
}
222+
return value;
223+
});
224+
return JSON.parse(json);
225+
}
226+
return value;
216227
}
217228

218229
return value;

0 commit comments

Comments
 (0)