MCPcopy
hub / github.com/subquery/subql / toJsonObject

Function toJsonObject

packages/common/src/project/utils.ts:318–329  ·  view source on GitHub ↗
(object: unknown)

Source from the content-addressed store, hash-verified

316}
317
318export function toJsonObject(object: unknown): unknown {
319 // When using plainToInstance or plainToClass, Map types will need to be converted to a JSON object
320 // https://github.com/typestack/class-transformer/issues/1256#issuecomment-1175153352
321 return JSON.parse(
322 JSON.stringify(object, (_, value: unknown) => {
323 if (value instanceof Map) {
324 return mapToObject(value);
325 }
326 return value;
327 })
328 );
329}
330
331export function mapToObject(map: Map<string | number, unknown>): Record<string | number, unknown> {
332 // XXX can use Object.entries with newer versions of node.js

Callers 4

project.spec.tsFile · 0.90
deploymentFunction · 0.90
toYamlMethod · 0.90

Calls 1

mapToObjectFunction · 0.85

Tested by

no test coverage detected