Subject: use simple_json library Author: Olivier Sallou Description: json.org library is not "free", use simple_json library and update according to API . [ Gilles Filippini ] Patche updated to migrate away from deprecated json-simple 1.x classes See json-simple 2.0.0 changelog: > * Deprecated JSONParse and JSONValue in favor of Jsoner. > * Deprecated JSONStreamAware and JSONAware in favor of Jsonable. > * Deprecated JSONObject in favor of JsonObject. > * Deprecated JSONArray in favor of JsonArray. . This patch now uses the new json-simple Json* classes. It is compatible with both 2.x and 3.x json-simple releases, with a few ajustments regarding backward incompatible changes in json-simple 3.x: - The package name, changed to com.github.cliftonlabs.json_simple This change is handled using place-holders @JSON_SIMPLE_PACKAGE@ which are substituted at build time by debian/rules. . With this trick the package is compatible with json-simple 2.x and 3.x. Last-Updated: 2020-05-15 Index: biojava4-live-4.2.12+dfsg/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java =================================================================== --- biojava4-live-4.2.12+dfsg.orig/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java +++ biojava4-live-4.2.12+dfsg/biojava-ws/src/main/java/org/biojava/nbio/ws/hmmer/RemoteHmmerScan.java @@ -20,8 +20,10 @@ */ package org.biojava.nbio.ws.hmmer; -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; +import @JSON_SIMPLE_PACKAGE@.JsonArray; +import @JSON_SIMPLE_PACKAGE@.JsonObject; +import @JSON_SIMPLE_PACKAGE@.Jsoner; + import org.biojava.nbio.core.sequence.ProteinSequence; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -136,15 +138,13 @@ public class RemoteHmmerScan implements SortedSet results = new TreeSet(); try { - JSONObject json = JSONObject.fromObject(result.toString()); - - JSONObject hmresults = json.getJSONObject("results"); - + JsonObject json= Jsoner.deserialize(result.toString(), (JsonObject) null); + JsonObject hmresults = (JsonObject) json.get("results"); - JSONArray hits = hmresults.getJSONArray("hits"); + JsonArray hits = (JsonArray) hmresults.get("hits"); for(int i =0 ; i < hits.size() ; i++){ - JSONObject hit = hits.getJSONObject(i); + JsonObject hit = (JsonObject) hits.get(i); HmmerResult hmmResult = new HmmerResult(); @@ -168,11 +168,11 @@ public class RemoteHmmerScan implements hmmResult.setPvalue((Double)hit.get("pvalue")); hmmResult.setScore(Float.parseFloat((String)hit.get("score"))); - JSONArray hmmdomains = hit.getJSONArray("domains"); + JsonArray hmmdomains = (JsonArray) hit.get("domains"); SortedSet domains = new TreeSet(); for ( int j= 0 ; j < hmmdomains.size() ; j++){ - JSONObject d = hmmdomains.getJSONObject(j); + JsonObject d = (JsonObject) hmmdomains.get(j); Integer is_included = getInteger(d.get("is_included")); if ( is_included == 0) { continue;