There was an error manipulating the JSON object

Hi we are using Virtuoso in our portal, and when the system is trying the query so it can proccess the data, we get the followed error:

2020-05-21 15:01:37,730 [main] INFO  semantic.sync.SemanticSyncProcess - Trying query:
2020-05-21 15:01:37,764 [main] ERROR semantic.sync.SemanticSyncProcess - There was an error manipulating the JSON object.
org.json.JSONException: A JSONObject text must begin with '{' at 0 [character 1 line 1]
	at org.json.JSONTokener.syntaxError(
	at org.json.JSONObject.<init>(
	at org.json.JSONObject.<init>(
	at semantic.sync.Utils.datasetsCountVirtuoso(
	at semantic.sync.SemanticSyncProcess.main(
2020-05-21 15:01:37,765 [main] INFO  semantic.sync.SemanticSyncProcess - -1 datasets in Virtuoso
2020-05-21 15:01:37,765 [main] ERROR semantic.sync.SemanticSyncProcess - The number of datasets in Virtuoso is less than or equal to 0. Something went wrong.
2020-05-21 15:01:37,765 [main] INFO  semantic.sync.SemanticSyncProcess - End of process

The JSON that is giving as a response is:

{ "head": { "link": [], "vars": ["datasetCount"] },
  "results": { "distinct": false, "ordered": true, "bindings": [ ] } }

We’ve seen there’s a line break before the “{” making this the line 1 instead of line 0.

We have checked with another example and they have the same line break and everything works perfectly, so we don’t longer believe there’s a relation with the line break. However, we have kept checking all our config and we still don’t understand why this is not working.
Any help is welcome.
Thank you.

When I run the JSON response you indicate as being returned from Virtuoso ie

{ "head": { "link": [], "vars": ["datasetCount"] },
  "results": { "distinct": false, "ordered": true, "bindings": [ ] } }

like , it is reported as being Valid JSON , so the problem seems to be in the application layer rather then Virtuoso …

What do you mean by “in the application layer”?
Because we have checked in our other environment and the JSON is giving more parameters in their JSON:

{ "head": { "link": [], "vars": ["datasetCount"] },
  "results": { "distinct": false, "ordered": true, "bindings": [
    { "datasetCount": { "type": "typed-literal", "datatype": "", "value": "27037" }} ] } }

Could be this “bindings” value make an effect on our Virtuoso making it not accept the JSON?

By application layer I mean whatever Java application is seeking to process the JSON result being by Virtuoso and generating the org.json.JSONException: A JSONObject text must begin with '{' at 0 [character 1 line 1] error, which I presume to this semantic.sync.SemanticSyncProcess application/module.

Where are you seeking to insert JSON data into Virtuoso that it might not be accepting, as from the query snippet originally post, I only see a SPARQL select ... query being executed ?