FluentJson.NET icon indicating copy to clipboard operation
FluentJson.NET copied to clipboard

Difference Between this and KO.Mapping?

Open chobo2 opened this issue 13 years ago • 2 comments

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?

chobo2 avatar Jul 03 '12 21:07 chobo2

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 avatar Jul 04 '12 16:07 paultyng

@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.

NickVanderPyle avatar Oct 08 '12 21:10 NickVanderPyle