/** * Returns a JSON object (as {@link Map}<String, Object>) of the wrapped erlang value. * * @return the converted value * @throws ClassCastException if thrown if a conversion is not possible, i.e. the type is not * supported */ public Map<String, Object> jsonValue() throws ClassCastException { /* * object(): {struct, [{key::string() | atom(), value()}]} * array(): {array, [value()]} * value(): number(), string(), object(), array(), 'true', 'false', 'null' * * first term must be an object! */ final OtpErlangTuple value_tpl = (OtpErlangTuple) value; if ((value_tpl.arity() == 2) && value_tpl.elementAt(0).equals(CommonErlangObjects.structAtom)) { final ErlangValueJSONToMap json_converter = new ErlangValueJSONToMap(); return json_converter.toJava((OtpErlangList) value_tpl.elementAt(1)); } else { throw new ClassCastException("wrong tuple arity"); } }