lundi 23 février 2015

JSON field - Parse String to Int

Have a relatively simple (I think) issue, but being a novice to JSON cannot seem to find a neat solution.


I have an Entity object with Id field as type Integer. However, the incoming Json data to be mapped has the id as a string.


With this a straightforward map does not seem to be possible. Is there a way to change the string data in the JSON to an integer, before mapping?


Example Json data



{"Id": "021", "userAge": 99}


Example Entity



@Entity


public class User{



@id
int userId;
int userAge;


}


Many thanks.


Aucun commentaire:

Enregistrer un commentaire