package foundation.json;
|
|
import java.math.BigDecimal;
|
|
import org.json.JSONArray;
|
import org.json.JSONObject;
|
|
public enum JType {
|
|
Root, Object, Array, String, Number, Empty, Unknown;
|
|
public static JType getInstance(Object value) {
|
if (value == null) {
|
return Empty;
|
}
|
|
if (value instanceof String) {
|
return String;
|
}
|
|
if (value instanceof JSONObject) {
|
return Object;
|
}
|
|
if (value instanceof JSONArray) {
|
return Array;
|
}
|
|
if (value instanceof Integer) {
|
return Number;
|
}
|
|
if (value instanceof Long) {
|
return Number;
|
}
|
|
if (value instanceof Double) {
|
return Number;
|
}
|
|
if (value instanceof BigDecimal) {
|
return Number;
|
}
|
|
return Unknown;
|
}
|
}
|