3

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
  • 41
  • 1
  • 1
  • 7
  • Look for Gson (https://code.google.com/p/google-gson/) – ceekay May 22 '15 at 11:18
  • 1
    Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are **off-topic** for Stack Overflow – Ed George May 22 '15 at 11:19

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
  • 841
  • 1
  • 7
  • 23