mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Remove Slime Java Commons submodule, (#236)
This commit is contained in:
57
java/org/json/JSONUtil.java
Normal file
57
java/org/json/JSONUtil.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package org.json;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
public class JSONUtil {
|
||||
|
||||
public static JSONObject toJSON(JSONEntry... entries) {
|
||||
return o(entries);
|
||||
}
|
||||
|
||||
public static JSONObject o(JSONEntry... entries) {
|
||||
JSONObject object = new JSONObject();
|
||||
for (int i = 0; i < entries.length; ++i) {
|
||||
JSONEntry e = entries[i];
|
||||
object.put(e.getKey(), e.getValue());
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public static JSONArray a(Object... values) {
|
||||
return new JSONArray(values);
|
||||
}
|
||||
|
||||
public static JSONEntry e(String k, Object v) {
|
||||
return new JSONEntry(k, v);
|
||||
}
|
||||
|
||||
public static class JSONEntry implements Entry<String, Object> {
|
||||
|
||||
private String key;
|
||||
private Object value;
|
||||
|
||||
public JSONEntry(String key, Object value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setValue(Object value) {
|
||||
Object oldValue = this.value;
|
||||
this.value = value;
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user