Sys.Debug
Sys.Debug gives app code the JSON serializer Lowgile uses to send objects between server and client. It is useful for inspecting objects while debugging: unlike JSON.stringify(), it records each object’s class and handles circular references, so the result can be turned back into objects of the same classes.
Availability: Both
Properties
Section titled “Properties”jsonMapper
Section titled “jsonMapper”const jsonMapper: JsonClassSerializerA preconfigured instance of JsonClassSerializer from the package @sumbricht/json-class-serializer (^1.1.0). It writes each object’s class name into a __type property and replaces repeated or circular references with $ref markers. When reading, it doesn’t fail if the root object has no known class; it then returns a plain object.
See the json-class-serializer documentation for its methods. The ones you need most are serializeToJson(), serializeToObject(), deserializeFromJson() and deserializeFromObject().
const json = Sys.Debug.jsonMapper.serializeToJson(myEntity)console.log(json)const copy = Sys.Debug.jsonMapper.deserializeFromJson(json)Note
Server-side code reaches the serializer as Sys.Debug.Debug.jsonMapper (see Debug below). Shared code is type-checked against Sys.Debug.jsonMapper, but when it runs on the server that is undefined.
Type: JsonClassSerializer · Availability: Client
export * as Debug from '@lg/shared/bridges/debug'On the server side, Sys.Debug holds a nested Debug namespace that contains jsonMapper, so the serializer is reached as Sys.Debug.Debug.jsonMapper. It is the same serializer as jsonMapper above.
Sys.Log.debug(Sys.Debug.Debug.jsonMapper.serializeToJson(myEntity))Type: { jsonMapper: JsonClassSerializer } · Availability: Server
Related
Section titled “Related”- Sys.Log
- Debugging your Lowgile app
- Sys API overview