loadJSONObject() fails to load compressed JSON provided by an API

Hi,
I had to use an API which now send compressed json.
loadJSONObject() fails to get thoses kind of json.

I did this workaround which seems to work.

import java.net.*;
import java.io.*;
import java.util.zip.GZIPInputStream;

void setup(){
size(200,200);
JSONObject json=getData("http://bla-bla");  
JSONArray values = json.getJSONArray("measure-groups");
println(values.size()); 
noLoop();
}

JSONObject getData(String urlsite){
  StringList sb;
  JSONObject json = new JSONObject();
  try{
    URL url = new URL(urlsite);
    URLConnection conn = url.openConnection();  
    conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
    BufferedReader in = new BufferedReader(new InputStreamReader(new GZIPInputStream(conn.getInputStream()), "UTF-8"));
    String readLine;
    sb = new StringList();
    while ( (readLine = in.readLine ()) != null) {
      System.out.println(readLine);
      sb.append(readLine + '\n');
    }
    json = parseJSONObject(sb.get(0));
    in.close();
  }catch (MalformedURLException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return json;
}

Remarks ?
Thank you

Hi @fabwoj ,

Please open an issue on github and give a minimalistic example to reproduce the issue.

Cheers
— mnse

Done.

https://github.com/processing/processing4/issues/710

Regards.