MCPcopy Create free account
hub / github.com/loopbackio/loopback-next / asJSON

Function asJSON

packages/repository/src/model.ts:294–304  ·  view source on GitHub ↗
(value: any)

Source from the content-addressed store, hash-verified

292}
293
294function asJSON(value: any): any {
295 if (value == null) return value;
296 if (typeof value.toJSON === 'function') {
297 return value.toJSON();
298 }
299 // Handle arrays
300 if (Array.isArray(value)) {
301 return value.map(item => asJSON(item));
302 }
303 return value;
304}
305
306/**
307 * Convert a value to a plain object as DTO.

Callers 1

copyPropertyAsJsonMethod · 0.85

Calls 1

toJSONMethod · 0.45

Tested by

no test coverage detected