It is a bit opaque, but certainly doable with the API. The tricky part is how to use the existing Cytoscape.js writer. To do this, you'll need to get the service from OSGi. The service class is CyNetworkViewWriterFactory and to make sure you get the right one, the ID is cytoscapejsNetworkWriterFactory, so it would be something like:
String filter = "("+ID+"=cytoscapejsNetworkWriterFactory)"
CyNetworkViewWriterFactory writeCyJs = serviceRegistrar.getService(CyNewtorkViewWriterFactory.class, filter);
// Open your output stream
CyWriter jsonWriter = writeCyjs.createWriter(outputStream, networkView);
jsonWriter.run();
Assuming you've already gotten the CyServiceRegistrar service. The trick is to be able to use the filter to get the correct network view writer factory. Hope this helps!
-- scooter