Environment versions
Network:
Windows 2008 Server
>>Hi,
>>
>>I have been Googling on the topic of how to serialize a dataset to JSon, then store it in the local storage and then convert it back to the dataset.
>>
>>In some posts I see people use JsonConvert() and in some other cases there is a code to "manually' convert dataset to a string. Which method is more efficient, in your opinion? In one thread (on Stackoverflow) the person says that JsonConvert() stores the column name for each column and each row into a string. This seems to be a pretty big waste of storage (given that the local storage is limited).
>>What do you think?
Firstly I wouldn't try to convert a dataset to Json - use as simple a class as possible. Don't know if you are using EF - that provides an easy way for this.
WebApi automatically used NewtonSoft.Json to convert C# objects to Json if that type is requested (or set as the default type). The column name has to be repeated for each property - that's the nature of Json. In practice it's not a problem - still more compact to send over the wire than XML.
I'm routinely storing arrays of 200~ objects (each with 10-12 properties) in local storage on the browser under one key. Only problem is that if you want to modify one object you have to load them all, make the change, and re-save - but again I've not found it too process intensive.
HTH,
Viv
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only