Is there an easy way to get JSON from a webservice and put it into my SQLite DB in C# mono for android (xamarin)? There are some tedious ways to do it but I want something quick and elegant.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
I made the following class to handle this when using
@SerializedName
annotations, it also adds support for ignoring certain fields. Hope it helps someone.You'll need to replace a few things there which are custom to my app, just the date format and Print function.
The question is old, but here is the equivalent code of @gghuffer in Java:
For use this, you need to use the library of
Gson
and define java classes for all yourjson
(i.e. 1 object - 1 json), then, for every class, you need to implement the following piece of code:Finally, you have your json string
jsonStr
, so:Hope this helps
I made a static class that will convert any object into contentvalues using reflection. I'm sure there's an equivalent way to do this in Java. Put your JSON objects into a class of some sort and this will convert all of the properties into contentvalues.