@Test public void booleanIsSortOfNumber() { assertEquals(JSON.numberValue(Boolean.TRUE), Integer.valueOf(1)); assertEquals(JSON.numberValue(Boolean.FALSE), Integer.valueOf(0)); }
public static Number numberValue(Object val) { if (val instanceof String) { try { return Double.valueOf((String)val); } catch (NumberFormatException ex) { return Double.NaN; } } if (val instanceof Boolean) { return (Boolean)val ? 1 : 0; } return (Number)val; }
JSON { public static Number numberValue(Object val) { if (val instanceof String) { try { return Double.valueOf((String)val); } catch (NumberFormatException ex) { return Double.NaN; } } if (val instanceof Boolean) { return (Boolean)val ? 1 : 0; } return (Number)val; } }
JSON { public static Number numberValue(Object val) { if (val instanceof String) { try { return Double.valueOf((String)val); } catch (NumberFormatException ex) { return Double.NaN; } } if (val instanceof Boolean) { return (Boolean)val ? 1 : 0; } return (Number)val; } private  JSON(); }
JSON { public static Number numberValue(Object val) { if (val instanceof String) { try { return Double.valueOf((String)val); } catch (NumberFormatException ex) { return Double.NaN; } } if (val instanceof Boolean) { return (Boolean)val ? 1 : 0; } return (Number)val; } private  JSON(); static Transfer findTransfer(BrwsrCtx c); static WSTransfer<?> findWSTransfer(BrwsrCtx c); static void readBindings(BrwsrCtx c, M model, Object value); static void extract(BrwsrCtx c, Object value, String[] props, Object[] values); static String toJSON(Object value); static String toString(BrwsrCtx c, Object obj, String prop); static Number toNumber(BrwsrCtx c, Object obj, String prop); static M toModel(BrwsrCtx c, Class<M> aClass, Object data, Object object); static boolean isSame(int a, int b); static boolean isSame(double a, double b); static boolean isSame(Object a, Object b); static int hashPlus(Object o, int h); static T extractValue(Class<T> type, Object val); static String stringValue(Object val); static Number numberValue(Object val); static Character charValue(Object val); static Boolean boolValue(Object val); static Object find(Object object, Bindings model); static Object find(Object object); static void applyBindings(Object object, String id); static void register(Class c, Proto.Type<?> type); static boolean isModel(Class<?> clazz); static Model bindTo(Model model, BrwsrCtx c); static T readStream(BrwsrCtx c, Class<T> modelClazz, InputStream data, Collection<? super T> collectTo); static T read(BrwsrCtx c, Class<T> modelClazz, Object data); }
JSON { public static Number numberValue(Object val) { if (val instanceof String) { try { return Double.valueOf((String)val); } catch (NumberFormatException ex) { return Double.NaN; } } if (val instanceof Boolean) { return (Boolean)val ? 1 : 0; } return (Number)val; } private  JSON(); static Transfer findTransfer(BrwsrCtx c); static WSTransfer<?> findWSTransfer(BrwsrCtx c); static void readBindings(BrwsrCtx c, M model, Object value); static void extract(BrwsrCtx c, Object value, String[] props, Object[] values); static String toJSON(Object value); static String toString(BrwsrCtx c, Object obj, String prop); static Number toNumber(BrwsrCtx c, Object obj, String prop); static M toModel(BrwsrCtx c, Class<M> aClass, Object data, Object object); static boolean isSame(int a, int b); static boolean isSame(double a, double b); static boolean isSame(Object a, Object b); static int hashPlus(Object o, int h); static T extractValue(Class<T> type, Object val); static String stringValue(Object val); static Number numberValue(Object val); static Character charValue(Object val); static Boolean boolValue(Object val); static Object find(Object object, Bindings model); static Object find(Object object); static void applyBindings(Object object, String id); static void register(Class c, Proto.Type<?> type); static boolean isModel(Class<?> clazz); static Model bindTo(Model model, BrwsrCtx c); static T readStream(BrwsrCtx c, Class<T> modelClazz, InputStream data, Collection<? super T> collectTo); static T read(BrwsrCtx c, Class<T> modelClazz, Object data);  }