Difference Between this and KO.Mapping?
Hey
I am wondering what the difference between this and KO Mapping are.
Instead of writing out my questions I posted all of them on stackoverflow ( http://stackoverflow.com/questions/11055336/how-to-use-knockout-js-with-asp-net-mvc-viewmodels)
I am wondering will FluentJson.Net solve any of the problems I am facing?
The main difference is client side vs server side. ko.mapping is a client side javascript for mapping your JSON objects, this library can generate a knockout viewmodel from the server side to eliminate a step.
If you are going to have a lot of back and forth with the server I would recommend ko.mapping, if you are mostly one way (ie. server -> client), this may be a good fit.
@paultyng you mentioned that FluentJson avoids the client side mapping of JSON to viewmodel. I did a quick and dirty performance comparison and came up with a few numbers.
I emitted a series of arrays of simple objects (4 properties: numbers, strings, and a boolean). ko.Mapping 10 items took 4ms. ko.Mapping 1,000 items took 390ms. ko.Mapping 10,000 items took 32sec!
Emitting a pre-mapped JS literal with FluentJson avoided the cost of auto-mapping on the browser. There was no additional performance hit from FluentJson.
Granted, it's probably a bad idea to automap >1,000 items and my test was for a narrow purpose. It's good to know the potential performance difference.