Example usage for org.json JSONObject getClass

List of usage examples for org.json JSONObject getClass

Introduction

In this page you can find the example usage for org.json JSONObject getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:run.ace.Utils.java

public static Object deserializeObjectOrStruct(JSONObject obj) {
    try {//  ww  w.  j  a v a  2 s .  com
        String type = obj.getString("_t");
        if (type.equals("H")) {
            return Handle.deserialize(obj);
        } else if (type.equals("Thickness")) {
            return Thickness.deserialize(obj);
        } else if (type.equals("GridLength")) {
            return GridLength.deserialize(obj);
        } else {
            throw new RuntimeException("Unhandled struct type: " + obj.getClass());
        }
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
}