Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 18.104.22.168 release ready!
Owner and Founder. Opencart
There is some problem, how to convert key-value pair type string data into Map of the class object?
Scenario- when we want to send a request object that has key-value pair property, Data comes from the .txt file, data base, or any resources that have key value pairs data. By using the GSON Library we can do it.
Gson is a Java library that can be used to parse the Java Objects into their JSON and vice-versa. It can also be used to convert a JSON string to an equivalent Java object. It is developed by the Google. for more about GSON click the link https://mobikul.com/introduction-gson-use/
So how we will solve?
Just we use the TokenType<T> generic class from com.google.gson.reflect package of GSON. TokenType class has property, Forces clients to create a subclass of this class which enables retrieval the type information even at runtime.
Here is my example, I am getting data from SQLite Database in my android application, and forces to convert key-value pair string into HashMap by using the gson.fromJson() method of GSON object, just passes the type object.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.