1

It seems ko.mapping.toJSON is calling stringifyJson: function (data, replacer, space) behind the closed doors, but it doesn't allow the caller to pass the optional params (replacer and space) so they can be passed along to stringifyJson.

Is there another overload or am I missing the whole point?

The actual story:

I am using ko.mapping.toJSON to json stringify my view model for sending back to server, which it does perfectly as it ignore all other properties that didn't came from store/db.

But I want to tweak it a little to save some KB's by leaving out null values.

rethabile
  • 3,029
  • 6
  • 34
  • 68
  • Why not use `ko.toJSON`? It allows the extra parameter https://stackoverflow.com/a/12461567/4887159 – Ray Sep 14 '18 at 13:54

1 Answers1

0

It seems indeed it does not currently support passing stringify optional params and the work around would be:

ko.toJSON(ko.mapping.toJS(....), replacer, space)
rethabile
  • 3,029
  • 6
  • 34
  • 68