I have an object array which I transform before submitting it to the controller.
Angular code to copy as follows:
sourceObjArray: SourceObject[] = [..];
targetObjArray: SourceObject[]= [];
targetObjArray = object.assign(sourceObjArray);
// when i change target object it also cause source object to change
transformSourceObject(targetObjArray)
The following seems to be working:
targetObjArray = object.assign({}, sourceObjArray);
// when i call transform it does not effect source object :)
transformSourceObject(targetObjArray)
but it causes a the following problem.
Could not read document: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: java.io.PushbackInputStream@302753d0; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: java.io.PushbackInputStream@302753d0; line: 1, column: 1]
My controller method signature is:
@RequestMapping(.., method=RequestMethod.POST)
public save(@RequestBody List<Object>, BindResult bindResult){}