Is there a Java class that can be any Javascript object?

I am looking for a java class that can represent a dynamic javascript object. This is so that I can navigate from and to Json, providing easy access to data. I would like this class to have access methods similar to what you would expect in a javascript object.

Preferences p = new Preferences(...);

p.getString("a");
p.getInteger("a");
p.getObject("a");

All of the above would pass to the appropriate type or return zero. Now the key part should be like this:

p.getString("a.b.c");
p.getString("a[0].b.d[1]");

Etc. Is there something already done that handles this?

+3
source share
2 answers

If you are trying to translate between JSON and Java, Gson is a good bet.

+3

HashMaps.. JavaScript- , .

.., JsObject , HashMap .

JSON Java, Jackson.

+1

Source: https://habr.com/ru/post/1779850/


All Articles