GDataDB icon indicating copy to clipboard operation
GDataDB copied to clipboard

Deserializing failes with header wichi has underscore for its name

Open kimsama opened this issue 12 years ago • 2 comments

Recently, I've cloned GDataDB from github and import it to Unity3D which is based on Mono.

It works fine except one.

The problem is that a property which has '_' for its name didn't work properly as it is expected.

See the following as an example:

public class MissionData { public int id { get; set; } public string key { get; set; } public string screen_name { get; set; } public string enemy_keys { get; set; } public int cost_energy { get; set; } public int rewardxp { get; set; } public int reward_money { get; set; } public string reward_package_key { get; set; } }

The class MissionData has several properties which has '_' for its name as 'screen_name'.

Then tried to retrieved data from the google spreadsheet as the sample code:

var client = new DatabaseClient(username, password); var db = client.GetDatabase(testSheetName); var table = db.GetTable<MissionData>(tableName); var all = table.FindAll(); ...

The value of the properties 'id' and 'key' are collect what it's value on the spreadsheet but 'screen_name' has nothing.

So I removed all '_' from properties name and then it works.

The problem was that Serializer<T>.Deserialize(in Serializer.cs) does not retrieve correct property if the property has underscore within its name.

Is that known issue or any way to fix that problem?

kimsama avatar Mar 26 '13 04:03 kimsama

After hanging on googling, found the below:

https://groups.google.com/forum/embed/?place=forum%2Fgoogle-spreadsheets-api&showsearch=true#!searchin/google-spreadsheets-api/underscore/google-spreadsheets-api/kwPoMl_V0SM/F9w0t16zV-AJ

It seems to be that there are some header naming rules but not clear what exactly it is.

kimsama avatar Mar 26 '13 04:03 kimsama

Yes, it seems to be an issue with the gdata API. I found:

https://productforums.google.com/d/msg/docs/gM5l95M1tQo/HaY_ghSImwIJ http://stackoverflow.com/questions/7108001/google-spreadsheets-api-removes-underscore

It seems that switching from list feed to cell feed works around this problem. This would require some non-trivial refactorings in GDataDB.

mausch avatar Mar 26 '13 15:03 mausch