An example javascript function that passes JSON data to a Java applet

I just started developing applets. I want to be able to pass (JSON) data from a javascript function to a method in my applet.

Although I searched, I cannot find a suitable example that shows how to do this. Maybe someone asks either to show a link to a resource that shows how to do this, or insert a few lines here to show how to do this.

Also, I have ff questions:

  • Is there a limit on the size of the JSON string that can be passed from JSON to the applet? (if so - what is it?)
  • Is it possible to compress (zip) a long string before passing it from JSON to the applet?
+5
source share
1

JavaScript JSON2, JSON,

var jsn = JSON.stringify({"x": "y"});

:

var applet = document.getElementById("myApplet");
applet.setJSONData(jsn);

, , , . Java Jackson JSON Java beans:

public class MyApplet extends JApplet {
    public void setJSONData(String data) {
        ObjectMapper mapper = new ObjectMapper();
        Map map = mapper.readValue(data, Map.class);
        // TODO sth with map
    };
}

, ASCII, , JSON, , UTF-8, HTML-.

, JSObject Java Plugin 2 JSON.

+2

All Articles