fileResource.setContents("[]"); //same as Json.createArrayBuilder().build().toString()
here it throws the exception:
org.jboss.forge.addon.resource.ResourceException: Error while setting the Json contents
at org.jboss.forge.addon.parser.json.resource.JsonResourceImpl.setContents(JsonResourceImpl.java:98)
at org.jboss.forge.addon.parser.json.resource.JsonResourceImpl.setContents(JsonResourceImpl.java:29)
I think the error is because JsonResource tries to read an object (instead of an array in the case) in set contents(JsonResourceImpl line 93):
setContents(reader.readObject());