Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a equivalent to JSON.Net in Java? [duplicate]

Tags:

java

json

android

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;
like image 635
Ash Avatar asked Sep 29 '25 10:09

Ash


1 Answers

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);
like image 103
Stugal Avatar answered Oct 02 '25 06:10

Stugal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!