Package com.google.gwt.json.client

Examples of com.google.gwt.json.client.JSONNumber


    protected void put( String key, Number value )
    {
        JSONValue val = JSONNull.getInstance();
        if ( value != null )
        {
            val = new JSONNumber( value.doubleValue() );
        }
        m_jsonObj.put( key, val );
    }
View Full Code Here


        m_jsonObj.put( key, val );
    }

    protected Double getDouble( String key )
    {
        JSONNumber num = getNumber( key );
        return num == null ? null : new Double( num.doubleValue() );
    }
View Full Code Here

        return num == null ? null : new Double( num.doubleValue() );
    }

    protected Integer getInteger( String key )
    {
        JSONNumber num = getNumber( key );
        return num == null ? null : new Integer( (int) num.doubleValue() );
    }
View Full Code Here

    }

    public JSONObject toJson(Item item) {
        JSONObject result = new JSONObject();
        result.put(KEY, new JSONString(toNullableValue(item.getKey())));
        result.put(ID, new JSONNumber(item.getId()));
        result.put(TEXT, new JSONString(item.getText()));
        result.put(PRIORITY, new JSONString(item.getPriority().toString()));
        result.put(STATUS, new JSONString(item.getStatus().toString()));
        result.put(CREATED, new JSONNumber(item.getCreated().getTime()));
        result.put(UPDATED, new JSONNumber(item.getUpdated().getTime()));
        return result;
    }
View Full Code Here

    public JSONObject toJson(Document document) {
        JSONObject result = new JSONObject();
        result.put(USER_ID, new JSONString(document.getUserId()));
        result.put(LAST_SAVED,
            new JSONNumber(document.getLastSaved().getTime()));
        return result;
    }
View Full Code Here

     * @return a JSONObject of Slider options
     */
    public static JSONObject getOptions(int min, int max, int[] defaultValues)
    {
        JSONObject options = new JSONObject();
        options.put(SliderOption.MIN.toString(), new JSONNumber(min));
        options.put(SliderOption.MAX.toString(), new JSONNumber(max));
        JSONArray vals = intArrayToJSONArray(defaultValues);
        options.put(SliderOption.VALUES.toString(), vals);
        return options;
    }
View Full Code Here

    private static JSONArray intArrayToJSONArray(int[] values)
    {
        JSONArray vals = new JSONArray();
        for (int i = 0, len = values.length; i < len; i++) {
            vals.set(i, new JSONNumber(values[i]));
        }
        return vals;
    }
View Full Code Here

       
        String testString = "Test String";
       
        JSONObject obj = new JSONObject();
        obj.put("stringVal", new JSONString(testString));
        obj.put("intVal", new JSONNumber(99));
        obj.put("intStringVal", new JSONString("99"));
        obj.put("booleanVal", JSONBoolean.getInstance(true));
        obj.put("booleanStringVal", new JSONString("true"));
        obj.put("dateStringVal", new JSONString("1293373801745"));
       
View Full Code Here

        }

        try {
            JSONValue v = obj.get(key);
            if (v != null) {
                JSONNumber n = v.isNumber();
                if (n != null) {
                    return (int) n.doubleValue();
                } else {
                    /*
                     * If this isn't a number, then it might be a string
                     * like "5" so we try to parse it as a number.
                     */
 
View Full Code Here

        }

        try {
            JSONValue v = obj.get(key);
            if (v != null) {
                JSONNumber n = v.isNumber();
                if (n != null) {
                    return n.doubleValue();
                } else {
                    /*
                     * If this isn't a number, then it might be a string
                     * like "5" so we try to parse it as a number.
                     */
 
View Full Code Here

TOP

Related Classes of com.google.gwt.json.client.JSONNumber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.