mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-05 18:01:56 +02:00
58 lines
1.0 KiB
Java
58 lines
1.0 KiB
Java
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;
|
|
}
|
|
|
|
}
|
|
}
|