Skip to content

Serialize Private Arguments via prefix (defaults to "_") #1

@johnstrickler

Description

@johnstrickler

Many classes use private variables that are prefixed with an underscore. These are exposed using getters/setters. The JSON payload doesn't use underscores.

This library should allow for automatic checking and serialization.

Example -

Getters and Setters

 class Bar {

   constructor(private _foo: string} {
 
   }
  
   get foo() { return this._foo; };

   }
}

Usage:

let bar = TSON.parse('{"foo":"something"}', Bar);

// "foo" serializes directly into Bar's _foo property
bar.foo == 'something'; // is true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions