2

My backend web service sometimes needs to return NaN or infinite values. However, there is no standard JSON representation of such values.

On the front end, we are using angular. Does its http client have some support/convention for reading such values from a json response?

blue_note
  • 27,712
  • 9
  • 72
  • 90
  • 1
    For NaN you could use `null`, and infinite could be `Number.MAX_SAFE_INTEGER`. Either that or make it an object with some properties that fill your need. – fredrik Jan 31 '19 at 12:20
  • 1
    You could replace NaN/infinite with `null`/`undefined`/`Number.MAX_SAFE_INTEGER` with an Http Interceptor.(https://angular.io/api/common/http/HttpInterceptor) – Yassine Zeriouh Jan 31 '19 at 12:42
  • @YassineZeriouh: thanks, interesting – blue_note Jan 31 '19 at 12:46
  • you can not intercept the http responses for this, because its a value criteria, not a response criteria – Gaspar Jan 31 '19 at 13:07
  • I think [this answer](https://stackoverflow.com/a/21897413/3681565) is more what you are looking for – Gaspar Jan 31 '19 at 13:09

0 Answers0