I am currently working on a large JavaScript project, and I am struggling with mapping JSON input (from the backend) to my own JavaScript objects.
I use the MVVM JavaScript framework for knockout and although it does include a mapping plugin , it does not allow me to reassign properties. I want to achieve this because the JSON input is too small, and I would like to “smooth out” my JS objects. The following is an example.
Incoming data.
Object : { Description: { Id : 1, Title : 'ProductX' }, Price : { Last : 12, Currency : 3 } }
And I would like to reassign / hide this:
var mappedObject = { id : 1, title: 'ProductX', price : 12, currency : 3 }
Therefore, I would like to provide a mapping configuration that details which inclusion attributes should be mapped to outbound . Very similar to Dozer .
My question is: are there libraries that are capable of what I would like to achieve , or will this require me to create my own library?
javascript mapping
thomaux
source share