buchatsky/jinqu-ng-http

Implementing IJsonConverter

Closed this issue · 1 comments

  1. Implementing IJsonConverter for passing cuscom static converter with two methods:
  • revive() for JSON.parse
  • replace() for JSON.stringify
  1. Implementing a set of Date converters for converting strings to Date object if they match the respective RegExp mask:
  • JsonDateOnlyConverter
  • JsonDateTimeOffsetConverter
  • JsonDateConverter (combines the two)
export interface IJsonConverter {
    // from JSON
    revive?(/*this: any,*/key: string, val: any): any;
    // to JSON
    replace?(/*this: any,*/key: string, value: any): any;
}
...
export class AngularHttpProvider<TConverter extends IJsonConverter | void = void> implements IAjaxProvider<Response> {
    constructor(protected http: HttpClient, protected jsonConverter?: TConverter) { }
...
}

Implemented in v1.0.0