4

In C# I would Deserialize JSON like this, I want to know is there anything available in java that does it the same way? really like this way its clean simple and easy to work it. anyone have a equivalent to it?

  string json = @"{
      'Name': 'Bad Boys',
      'ReleaseDate': '1995-4-7T00:00:00',
      'Genres': [
        'Action',
        'Comedy'
      ]
    }";

Movie m = JsonConvert.DeserializeObject<Movie>(json);

string name = m.Name;
Ash
  • 51
  • 1
  • 1
  • 7

1 Answers1

5

I often use gson from google, it's very simple and does the job:

https://code.google.com/p/google-gson/

To deserialize object:

Movie movie = new Gson().fromJson(json, Movie.class);
Stugal
  • 850
  • 1
  • 8
  • 24