https://google.github.io/gson/apidocs/com/google/gson/reflect/TypeToken.html

20 views
Skip to first unread message

Сурманидзе Роман

unread,
Mar 29, 2018, 8:24:30 AM3/29/18
to ScriptCraft - Scripting Minecraft
Tell me please. How on JS do this:
 new TypeToken <Map <String, Object >> () {}. getType ()

Mike Stay

unread,
Mar 29, 2018, 10:46:40 AM3/29/18
to ScriptCraft - Scripting Minecraft
First you have to make Nashorn load the jar containing the class, but then I think you say

var myTypeToken = new com.google.gson.reflect.TypeToken() {};
myTypeToken.getType()

The first line isn't valid javascript, but Nashorn has a syntax extension to let you create anonymous classes.  See the fourth entry here:

Сурманидзе Роман

unread,
Mar 29, 2018, 5:28:03 PM3/29/18
to ScriptCraft - Scripting Minecraft
thank you very much
Reply all
Reply to author
Forward
0 new messages