Creates a new BranchUniversalObject with the data provided by {@link JSONObject}.

@param jsonObject {@link JSONObject} to create the BranchUniversalObject
@return A {@link BranchUniversalObject} corresponding to the Json data passed in
547961
public static BranchUniversalObject createInstance(JSONObject jsonObject) {
        
        BranchUniversalObject branchUniversalObject = null;
        try {
            branchUniversalObject = new BranchUniversalObject();
            BranchUtil.JsonReader jsonReader = new BranchUtil.JsonReader(jsonObject);
            branchUniversalObject.title_ = jsonReader.readOutString(Defines.Jsonkey.ContentTitle.getKey());
            branchUniversalObject.canonicalIdentifier_ = jsonReader.readOutString(Defines.Jsonkey.CanonicalIdentifier.getKey());
            branchUniversalObject.canonicalUrl_ = jsonReader.readOutString(Defines.Jsonkey.CanonicalUrl.getKey());
            branchUniversalObject.description_ = jsonReader.readOutString(Defines.Jsonkey.ContentDesc.getKey());
            branchUniversalObject.imageUrl_ = jsonReader.readOutString(Defines.Jsonkey.ContentImgUrl.getKey());
            branchUniversalObject.expirationInMilliSec_ = jsonReader.readOutLong(Defines.Jsonkey.ContentExpiryTime.getKey());
            JSONArray keywordJsonArray = null;
            Object keyWordArrayObject = jsonReader.readOut(Defines.Jsonkey.ContentKeyWords.getKey());
            if (keyWordArrayObject instanceof JSONArray) {
                keywordJsonArray = (JSONArray) keyWordArrayObject;
            } else if (keyWordArrayObject instanceof String) {
                keywordJsonArray = new JSONArray((String) keyWordArrayObject);
            }
            if (keywordJsonArray != null) {
                for (int i = 0; i < keywordJsonArray.length(); i++) {
                    branchUniversalObject.keywords_.add((String) keywordJsonArray.get(i));
                }
            }
            Object indexableVal = jsonReader.readOut(Defines.Jsonkey.PublicallyIndexable.getKey());
            if (indexableVal instanceof Boolean) {
                branchUniversalObject.indexMode_ = (Boolean) indexableVal ? CONTENT_INDEX_MODE.PUBLIC : CONTENT_INDEX_MODE.PRIVATE;
            } else if (indexableVal instanceof Integer) {
                // iOS compatibility issue. iOS send 0/1 instead of true or false
                branchUniversalObject.indexMode_ = (Integer) indexableVal == 1 ? CONTENT_INDEX_MODE.PUBLIC : CONTENT_INDEX_MODE.PRIVATE;
            }
            branchUniversalObject.localIndexMode_ = jsonReader.readOutBoolean(Defines.Jsonkey.LocallyIndexable.getKey()) ? CONTENT_INDEX_MODE.PUBLIC : CONTENT_INDEX_MODE.PRIVATE;
            branchUniversalObject.creationTimeStamp_ = jsonReader.readOutLong(Defines.Jsonkey.CreationTimestamp.getKey());
            
            branchUniversalObject.metadata_ = ContentMetadata.createFromJson(jsonReader);
            // PRS : Handling a  backward compatibility issue here. Previous version of BUO Allows adding metadata key value pairs to the Object.
            // If the Json is received from a previous version of BUO it may have metadata set in the object. Adding them to custom metadata for now.
            // Please note that #getMetadata() is deprecated and #getContentMetadata() should be the new way of getting metadata
            JSONObject pendingJson = jsonReader.getJsonObject();
            Iterator<String> keys = pendingJson.keys();
            while (keys.hasNext()) {
                String key = keys.next();
                branchUniversalObject.metadata_.addCustomMetadata(key, pendingJson.optString(key));
            }
            
        } catch (Exception ignore) {
        }
        return branchUniversalObject;
    }
544641
public static JSONObject toJsonObject(Map<String, ?> map) {
    JSONObject jsonObject = new JSONObject();
    for (Map.Entry<String, ?> entry : map.entrySet()) {
      Object value = wrap(entry.getValue());
      try {
        jsonObject.put(entry.getKey(), value);
      } catch (JSONException ignored) {
        // Ignore values that JSONObject doesn't accept.
      }
    }
    return jsonObject;
  }
391382
public static JSONObject fetchDirectoryObjectJSONObject(JSONObject jsonObject) throws Exception {
        JSONObject jObj = new JSONObject();
        jObj = jsonObject.optJSONObject("responseMsg");
        return jObj;
    }
75664
public JsonObject toJsonObject() {
        JsonObjectBuilder factory = Json.createObjectBuilder();
        if (nym != null) {
            JsonObjectBuilder factory2 = Json.createObjectBuilder();
            factory2.add("x", Base64.getEncoder().encodeToString(IdemixUtils.bigToBytes(nym.getX())));
            factory2.add("y", Base64.getEncoder().encodeToString(IdemixUtils.bigToBytes(nym.getY())));
            factory.add("nym", factory2.build());
        }

        if (issuerNonce != null) {
            String b64encoded = Base64.getEncoder().encodeToString(IdemixUtils.bigToBytes(issuerNonce));
            factory.add("issuer_nonce", b64encoded);
        }

        if (proofC != null) {
            factory.add("proof_c", Base64.getEncoder().encodeToString(IdemixUtils.bigToBytes(proofC)));
        }

        if (proofS != null) {
            factory.add("proof_s", Base64.getEncoder().encodeToString(IdemixUtils.bigToBytes(proofS)));
        }

        return factory.build();
    }
698919
public JSONObject toJSON() {
        JSONObject ret = new JSONObject();
        ret.put("url", url);
        if (env != null) {
            ret.put("env", env);
        }
        return ret;
    }
627646
public static JSONObject parseObj(Object obj, boolean ignoreNullValue, boolean isOrder) {
		return new JSONObject(obj, ignoreNullValue, isOrder);
	}
825726
static Map<String, ?> buildSourceByJsonMapper(Object sourceObject) {
        try {
            return JsonMapper.convertValue(sourceObject, MAP_TYPE_REFERENCE);
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndThrowRuntimeEx(log, e,
                    "buildSourceByJsonMapper", sourceObject);
        }
    }
882785
static private JsonTransformer factory(Object jsonObject) throws InvalidTransformerException {
        if (jsonObject instanceof JSONObject) {
            return factory((JSONObject)jsonObject);
        }
        else if (jsonObject instanceof JSONArray) {
            return factory((JSONArray)jsonObject);
        }
        else if (jsonObject instanceof String) {
            return factoryAction((String)jsonObject);
        }
        
        throw new InvalidTransformerException("Not supported transformer type: " + jsonObject);
    }
459540
public static EscEvent create(final JsonObject jsonObj) {
        final String eventId = jsonObj.getString(EL_EVENT_ID);
        final String eventType = jsonObj.getString(EL_EVENT_TYPE);
        final JsonObject jsonData = jsonObj.getJsonObject(EL_DATA);
        final JsonObject jsonMeta = jsonObj.getJsonObject(EL_META_DATA);
        return new EscEvent(UUID.fromString(eventId), eventType, new DataWrapper(jsonData), new DataWrapper(jsonMeta));
    }
150705
public JSONObject getJSONObject(String key) throws JSONException {
    Object o = get(key);
    if (o instanceof JSONObject) {
      return (JSONObject) o;
    }
    throw new JSONException("JSONObject[" + quote(key) + "] is not a JSONObject.");
  }
317909
public JsonObject getJsonObject(String name) throws JsonException {
        JsonElement el = get(name);
        if (!el.isJsonObject()) {
            throw Util.typeMismatch(name, el, "JsonObject");
        }
        return el.asJsonObject();
    }
523256
public static Object toBean( JSONObject jsonObject, Class beanClass ) {
      JsonConfig jsonConfig = new JsonConfig();
      jsonConfig.setRootClass( beanClass );
      return toBean( jsonObject, jsonConfig );
   }
622189
public JSONObject construct(){
        JSONObject payload = new JSONObject();
        payload.put(Names.MAIN_BRUSH.toString(), mainBrushWorkTime);
        payload.put(Names.SENSOR.toString(), sensorTimeSinceCleaning);
        payload.put(Names.SIDE_BRUSH.toString(), sideBrushWorkTime);
        payload.put(Names.FILTER.toString(), filterWorkTime);
        return payload;
    }
494544
public static List<Representation> parseRepresentations(JsonObject jsonObject) {
        List<Representation> representations = new ArrayList<Representation>();
        for (JsonValue representationJson : jsonObject.get("entries").asArray()) {
            Representation representation = new Representation(representationJson.asObject());
            representations.add(representation);
        }
        return representations;
    }
101574
public JSONObject toJSONObject() {
        JSONObject resp = new JSONObject();
        add(resp, URL,url);
        if (secured != null) {
            add(resp, SECURED, secured);
        }
        add(resp, SERVER_VENDOR, serverVendor);
        add(resp, SERVER_PRODUCT, serverProduct);
        add(resp, SERVER_VERSION, serverVersion);
        add(resp, AGENT_VERSION, agentVersion);
        add(resp, AGENT_ID, agentId);
        add(resp, AGENT_DESCRIPTION,agentDescription);
        return resp;
    }
920073
public static JSONObject getObject(JSONValue value) {
        if (value == null)
            return null;
        if (!(value instanceof JSONObject))
            throw new JSONException(NOT_AN_OBJECT);
        return (JSONObject)value;
    }
35144
public JSONObject getJSONObject(K key) {
		final Object object = this.getObj(key);
		if(null == object) {
			return null;
		}
		
		if(object instanceof JSONObject) {
			return (JSONObject) object;
		}
		return new JSONObject(object);
	}