1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
Subject: use simple_json library
Author: Olivier Sallou <osallou@debian.org>
Description: json.org library is not "free", use simple_json
library and update according to API
.
[ Gilles Filippini <pini@debian.org> ]
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<HmmerResult> results = new TreeSet<HmmerResult>();
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<HmmerDomain> domains = new TreeSet<HmmerDomain>();
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;
|