当前位置: 首页>>代码示例>>Java>>正文


Java JsonUtils类代码示例

本文整理汇总了Java中com.google.gwt.core.client.JsonUtils的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils类的具体用法?Java JsonUtils怎么用?Java JsonUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonUtils类属于com.google.gwt.core.client包,在下文中一共展示了JsonUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyAlphaMapMaterial

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
public void applyAlphaMapMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
    uniforms.put("channel", new JSONString("r"));

    JSONObject alphaMaterial = new JSONObject();
    alphaMaterial.put("type", new JSONString("AlphaMap"));
    alphaMaterial.put("uniforms", uniforms);

    JSONObject materials = new JSONObject();
    materials.put("alphaMaterial", alphaMaterial);

    JSONObject components = new JSONObject();
    components.put("diffuse", new JSONString("vec3(1.0)"));
    components.put("alpha", new JSONString("alphaMaterial.alpha"));

    JSONObject fabric = new JSONObject();
    fabric.put("materials", materials);
    fabric.put("components", components);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}
 
开发者ID:iSergio,项目名称:gwt-cs,代码行数:25,代码来源:Materials.java

示例2: applyWaterMaterial

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
public void applyWaterMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("specularMap", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
    uniforms.put("normalMap", new JSONString(GWT.getModuleBaseURL() + "images/waterNormals.jpg"));
    uniforms.put("frequency", new JSONNumber(10000.0));
    uniforms.put("animationSpeed", new JSONNumber(0.01));
    uniforms.put("amplitude", new JSONNumber(1.0));

    JSONObject fabric = new JSONObject();
    fabric.put("type", new JSONString("Water"));
    fabric.put("uniforms", uniforms);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}
 
开发者ID:iSergio,项目名称:gwt-cs,代码行数:17,代码来源:Materials.java

示例3: draw

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
private void draw() {
	JsArrayMixed dataArray = JsonUtils.unsafeEval("[['Mon',20,28,38,45],['Tue',31,38,55,66],['Wed',50,55,77,80],['Thu',77,77,66,50],['Fri',68,66,22,15]]");

	// Prepare the data
	DataTable dataTable = ChartHelper.arrayToDataTable(dataArray, true);

	// Set options
	CandlestickChartOptions options = CandlestickChartOptions.create();
	BackgroundColor bgColor = BackgroundColor.create();
	bgColor.setStroke("#2196f3");
	bgColor.setFill("#90caf9");
	bgColor.setStrokeWidth(2);
	
	
	
	options.setLegend(Legend.create(LegendPosition.NONE));
	options.setFallingColor(bgColor);
	options.setRisingColor(bgColor);

	// Draw the chart
	chart.draw(dataTable, options);
}
 
开发者ID:GwtMaterialDesign,项目名称:gwt-material-demo,代码行数:23,代码来源:MaterialCandleStick.java

示例4: draw

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
private void draw() {
	JsArrayMixed dataArray = JsonUtils
			.unsafeEval("[['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua  Guinea', 'Rwanda', 'Average'],['2004/05', 165, 938, 522, 998, 450, 614.6],['2005/06', 135, 1120, 599, 1268, 288, 682],['2006/07', 157, 1167, 587, 807, 397, 623],['2007/08', 139, 1110, 615, 968, 215, 609.4],['2008/09', 136, 691, 629, 1026, 366, 569.6]]");

	// Prepare the data
	DataTable dataTable = ChartHelper.arrayToDataTable(dataArray);

	// Set options
	ComboChartOptions options = ComboChartOptions.create();
	options.setFontName("Tahoma");
	options.setTitle("Monthly Coffee Production by Country");
	options.setHAxis(HAxis.create("Cups"));
	options.setVAxis(VAxis.create("Month"));
	options.setSeriesType(SeriesType.BARS);
	ComboChartSeries series = ComboChartSeries.create();
	series.setType(SeriesType.LINE);
	options.setSeries(5, series);

	// Draw the chart
	chart.draw(dataTable, options);
}
 
开发者ID:GwtMaterialDesign,项目名称:gwt-material-demo,代码行数:22,代码来源:MaterialComboCharts.java

示例5: getSavedItems

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private JsoArray<Entry> getSavedItems() {
	Storage storage = getStorage();

	if (storage != null) {
		String data = storage.getItem(SAVED_ITEMS);
		JsoArray<Entry> list = null;

		if (data != null) {
			list = JsonUtils.safeEval(data);
		} else {
			list = (JsoArray<Entry>) JavaScriptObject.createArray();
		}

		return list;

	} else {
		return (JsoArray<Entry>) JavaScriptObject.createArray();
	}
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:21,代码来源:GearPanel.java

示例6: testDynamicJsArray_length

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
/** Array of keys is accessible through the JSO. */
public void testDynamicJsArray_length() {
  DynamicJsArray arr = JsonUtils.safeEval("[1, \"a\", false]");
  assertEquals(3, arr.length());

  // Length can be increased arbitrarily, but items default to null.
  arr.setLength(6);
  assertEquals(6, arr.length());
  assertNull(arr.get(3));

  // Getting a non-existent element returns null.
  assertNull(arr.get(10));
  assertNull(arr.typeofIndex(10));

  // Array can be shortened, trimming items from the end.
  arr.setLength(1);
  assertEquals(1, arr.length());
  assertEquals(1, arr.getInteger(0));
  assertNull(arr.get(1));
}
 
开发者ID:showlowtech,项目名称:google-apis-explorer,代码行数:21,代码来源:DynamicJsArrayGwtTest.java

示例7: testDynamicJsArray_shift

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
/** shift() pops a value off the beginning of the array. */
public void testDynamicJsArray_shift() {
  DynamicJsArray arr = JsonUtils.safeEval("[false, 1.2, 12, \"a\", {\"a\":\"b\"}]");
  assertEquals(5, arr.length());

  assertFalse(arr.shiftBoolean());
  assertEquals(4, arr.length());

  assertEquals(1.2, arr.shiftDouble());
  assertEquals(3, arr.length());

  assertEquals(12, arr.shiftInteger());
  assertEquals(2, arr.length());

  assertEquals("a", arr.shiftString());
  assertEquals(1, arr.length());

  DynamicJso jso = arr.shift();
  assertEquals(0, arr.length());
  assertEquals(1, jso.keys().length());
  assertEquals("b", jso.getString("a"));

  // With nothing remaining, shift() returns null.
  assertNull(arr.shift());
}
 
开发者ID:showlowtech,项目名称:google-apis-explorer,代码行数:26,代码来源:DynamicJsArrayGwtTest.java

示例8: testDynamicJsArray_typeof

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
/** The type of data stored in the array is accessible as expected. */
public void testDynamicJsArray_typeof() {
  DynamicJsArray arr = JsonUtils.safeEval("[1.2, 12, \"foo\", false, [\"a\"], {\"fa\":\"bar\"}]");
  assertEquals(JsType.NUMBER, arr.typeofIndex(0));
  assertEquals(JsType.INTEGER, arr.typeofIndex(1));
  assertEquals(JsType.STRING, arr.typeofIndex(2));
  assertEquals(JsType.BOOLEAN, arr.typeofIndex(3));
  assertEquals(JsType.ARRAY, arr.typeofIndex(4));
  assertEquals(JsType.OBJECT, arr.typeofIndex(5));
}
 
开发者ID:showlowtech,项目名称:google-apis-explorer,代码行数:11,代码来源:DynamicJsArrayGwtTest.java

示例9: testDynamicJso_keys

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
/** Array of keys is accessible through the JSO. */
public void testDynamicJso_keys() {
  DynamicJso jso = JsonUtils.safeEval("{\"a\":{\"foo\":\"bar\"}}");
  assertEquals(1, jso.keys().length());
  assertEquals("a", jso.keys().get(0));

  jso = JavaScriptObject.createObject().cast();
  jso.set("a", true);
  jso.set("b", false);
  jso.set("c", 123);
  assertEquals(3, jso.keys().length());
  assertEquals("a", jso.keys().get(0));
  assertEquals("b", jso.keys().get(1));
  assertEquals("c", jso.keys().get(2));

  // Getting a non-existent key return null
  assertNull(jso.get("zzz"));
  assertNull(jso.typeofKey("zzz"));
}
 
开发者ID:showlowtech,项目名称:google-apis-explorer,代码行数:20,代码来源:DynamicJsoGwtTest.java

示例10: deserializeAsCollection

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response,
                                                           DeserializationContext context) {
    JsArray<T> jsArray = JsonUtils.safeEval(response);
    if (collectionType.equals(List.class) || collectionType.equals(Collection.class)) {
        return (C) new JsArrayList(jsArray);
    } else {
        C col = context.getContainerInstance(collectionType);
        for (int i = 0; i < jsArray.length(); i++) {
            T t = jsArray.get(i);
            col.add(t);
        }
        return col;
    }
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:17,代码来源:OverlaySerdes.java

示例11: test

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
protected void test(String json, String sql, JsArrayMixed args, String msg) throws Throwable {
    RootPanel.get().getElement().setAttribute("id", "rqb");

    try {
        if (json != null) {
            conf = (JsConfiguration) JsonUtils.unsafeEval(json);
            addHandlers(conf);
        }
        builder = RedQueryBuilder.configure(conf, sql, args);
        assertTrue(builder != null);
        if (msg != null) {
            fail("Was expecting the error message: " + msg);
        }
    } catch (Throwable th) {
        if (msg != null) {
            assertEquals(msg, th.getMessage());
        } else {
            throw th;
        }
    }
}
 
开发者ID:salk31,项目名称:RedQueryBuilder,代码行数:22,代码来源:AbstractTest.java

示例12: getRestAreas

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
private void getRestAreas() {
	String jsonString = AppBundle.INSTANCE.restAreaData().getText();
	RestAreaFeed restAreas = JsonUtils.safeEval(jsonString);
	RestAreaItem item;

	for (int i = 0; i < restAreas.getRestAreas().length(); i++){
		item = new RestAreaItem();
		item.setId(i);
		item.setRoute(restAreas.getRestAreas().get(i).getRoute());
		item.setLocation(restAreas.getRestAreas().get(i).getLocation());
		item.setDescription(restAreas.getRestAreas().get(i).getDescription());
		item.setMilepost(restAreas.getRestAreas().get(i).getMilepost());
		item.setDirection(restAreas.getRestAreas().get(i).getDirection());
		item.setLatitude(restAreas.getRestAreas().get(i).getLatitude());
		item.setLongitude(restAreas.getRestAreas().get(i).getLongitude());
		item.setNotes(restAreas.getRestAreas().get(i).getNotes());
		item.setHasDump(restAreas.getRestAreas().get(i).hasDump());
		item.setOpen(restAreas.getRestAreas().get(i).isOpen());
		item.setAmenities(restAreas.getRestAreas().get(i).getAmenities());
		restAreaItems.add(item);
	}
	drawRestAreasLayer();
}
 
开发者ID:WSDOT,项目名称:wsdot-mobile-app,代码行数:24,代码来源:TrafficMapActivity.java

示例13: onSubmit

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
public void onSubmit(String results) {
    initForm();
    JavaScriptObject jsResponse = JsonUtils.safeEval(results);

    if (jsResponse != null) {
        JSONObject response = new JSONObject(jsResponse);
        if (response.get("document") != null) {
            JSONObject document = response.get("document").isObject();

            DocumentData data = new DocumentData(document.get("fileName").isString().stringValue(),
                                                 new Double(document.get("size").isNumber().doubleValue()).longValue(),
                                                 null);

            data.setContentId(document.get("contentId").isString().stringValue());

            setValue(data,
                     true);
        } else if (response.get("error").isNull() != null) {
            setValue(null,
                     true);
        }
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:24,代码来源:DocumentFieldRendererViewImpl.java

示例14: getNumberArrayAttribute

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
private List<Double> getNumberArrayAttribute(SliderOption option, List<Double> defaultValue) {

        // Get array attribute
        JsArrayNumber array = null;
        if (isAttached()) {
            array = getNumberArrayAttribute(getElement(), option.getName());
        } else {
            String value = attributeMixin.getAttribute(option.getDataAttribute());
            if (value != null && !value.isEmpty()) {
                array = JsonUtils.safeEval(value);
            }
        }

        // Attribute not set
        if (array == null) {
            return defaultValue;
        }

        // Put array to list
        List<Double> list = new ArrayList<Double>(array.length());
        for (int i = 0; i < array.length(); i++) {
            list.add(array.get(i));
        }
        return list;
    }
 
开发者ID:gwtbootstrap3,项目名称:gwtbootstrap3-extras,代码行数:26,代码来源:SliderBase.java

示例15: getStringArrayAttribute

import com.google.gwt.core.client.JsonUtils; //导入依赖的package包/类
private List<String> getStringArrayAttribute(SliderOption option, List<String> defaultValue) {

        // Get array attribute
        JsArrayString array = null;
        if (isAttached()) {
            array = getStringArrayAttribute(getElement(), option.getName());
        } else {
            String value = attributeMixin.getAttribute(option.getDataAttribute());
            if (value != null && !value.isEmpty()) {
                array = JsonUtils.safeEval(value);
            }
        }

        // Attribute not set
        if (array == null) {
            return defaultValue;
        }

        // Put array to list
        List<String> list = new ArrayList<String>(array.length());
        for (int i = 0; i < array.length(); i++) {
            list.add(array.get(i));
        }
        return list;
    }
 
开发者ID:gwtbootstrap3,项目名称:gwtbootstrap3-extras,代码行数:26,代码来源:SliderBase.java


注:本文中的com.google.gwt.core.client.JsonUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。