Search code examples
jsonsavewinjsobservable

WinJS: Save observable objects without backingData etc. to JSON


what is the best way to save observable objects to JSON without _backingData etc.? For example instead of:

[{"_backingData":{"name":"Test","hourlyRate":""},"name":"Test","hourlyRate":"","id":-1,"number":"","backingData":{"name":"Test","hourlyRate":""}}]

This should be saved:

[{"name":"Test","hourlyRate":"","id":-1,"number":""}]

This is my code to save the data:

var data = JSON.stringify(value.concat());
            Windows.Storage.ApplicationData.current.localFolder.createFileAsync("customer.json", Windows.Storage.CreationCollisionOption.replaceExisting)
                .then(function (file) {
                    return Windows.Storage.FileIO.writeTextAsync(file, data);
                });

value is a WinJS.Binding.List().

Is there a simple solution to solve this "problem"?


Solution

  • use WinJS.Binding.unwrap over the individual elements in the array.