forked from I2P_Developers/i2p.i2p
Util: Update json-simple lib to 2.3.0 2017-10-04
Bundle 2.0 API only; remove 1.1 API Convert DoH, NDT, and i2pcontrol to the 2.x API Fix i2pcontrol handling of number values and serialization for 2.x API Remove xenial dependency on libjson-simple-java, it has only 1.1 Set min and max version constraint on libjson-simple-java for bionic+ Based on patch from Gilles Filippini ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901827 This does not support 3.x but the patch for that will be smaller.
This commit is contained in:
@ -30,9 +30,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import edu.internet2.ndt.Tcpbw100;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.json.simple.JsonObject;
|
||||
import org.json.simple.Jsoner;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataHelper;
|
||||
@ -153,10 +152,9 @@ public class MLabRunner {
|
||||
int code = eepget.getStatusCode();
|
||||
if (code != 200)
|
||||
throw new IOException("ns fetch failed: " + code);
|
||||
JSONParser parser = new JSONParser();
|
||||
byte[] b = baos.toByteArray();
|
||||
String s = new String(b, "ISO-8859-1");
|
||||
JSONObject map = (JSONObject) parser.parse(s);
|
||||
JsonObject map = (JsonObject) Jsoner.deserialize(s);
|
||||
if (map == null) {
|
||||
throw new IOException("no map");
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package edu.internet2.ndt;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
import org.json.simple.JsonObject;
|
||||
import org.json.simple.Jsoner;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@ -27,8 +27,7 @@ public class JSONUtils {
|
||||
* @return {int} obtained value from JSON map
|
||||
*/
|
||||
public static String getValueFromJsonObj(String jsonTxt, String key) {
|
||||
JSONValue jsonParser = new JSONValue();
|
||||
Map json = (Map)jsonParser.parse(new String(jsonTxt));
|
||||
Map json = (Map)Jsoner.deserialize(new String(jsonTxt), (JsonObject)null);
|
||||
if (json == null)
|
||||
return null;
|
||||
Iterator iter = json.entrySet().iterator();
|
||||
@ -49,11 +48,12 @@ public class JSONUtils {
|
||||
* @return {String} json object with added value.
|
||||
*/
|
||||
public static String addValueToJsonObj(String jsonTxt, String key, String value) {
|
||||
JSONValue jsonParser = new JSONValue();
|
||||
JSONObject json = (JSONObject)jsonParser.parse(new String(jsonTxt));
|
||||
JsonObject json = Jsoner.deserialize(new String(jsonTxt), (JsonObject)null);
|
||||
if (json == null)
|
||||
json = new JsonObject();
|
||||
json.put(key, value);
|
||||
|
||||
return json.toJSONString();
|
||||
return json.toJson();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,10 +63,10 @@ public class JSONUtils {
|
||||
* @return {byte[]} json object represented by jsontext and encodes into a sequence of bytes
|
||||
*/
|
||||
public static byte[] createJsonObj(byte[] msg) {
|
||||
JSONObject obj = new JSONObject();
|
||||
JsonObject obj = new JsonObject();
|
||||
obj.put("msg", new String(msg));
|
||||
|
||||
return obj.toJSONString().getBytes();
|
||||
return obj.toJson().getBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,9 +77,9 @@ public class JSONUtils {
|
||||
* @since 0.9.45
|
||||
*/
|
||||
public static byte[] createJsonLoginObj(byte[] msg, byte tests) {
|
||||
JSONObject obj = new JSONObject();
|
||||
JsonObject obj = new JsonObject();
|
||||
obj.put("msg", new String(msg));
|
||||
obj.put("tests", Integer.toString(tests & 0xff));
|
||||
return obj.toJSONString().getBytes();
|
||||
return obj.toJson().getBytes();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user