Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use json in java like in javascript

Tags:

java

json

I am trying to read a json file in java to order it. I know javascript and the way to read json in javascript is so easy to do what I want to do, json is just like an array. Is there a way to do something like that in java?

I just found gjson, json-lib, flexjson libraries and no one example about what I say, so I guess it is not possible to do it.

I need to do in java because it is for a restful server and it is all in java.

I guess I should have some classes to create all "things" inside json (in java) and put all of them in an array, after ordering them... But it makes me to have lot of classes which I don't.

like image 647
Biribu Avatar asked Oct 20 '25 16:10

Biribu


2 Answers

Have you read the gson user guide?

https://sites.google.com/site/gson/gson-user-guide

like image 176
heldt Avatar answered Oct 22 '25 07:10

heldt


I'd recommend using a JSon framework in Java, such as these examples.

like image 30
Michael Avatar answered Oct 22 '25 05:10

Michael



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!