Java Code Examples for com.taobao.weex.utils.WXJsonUtils

The following examples show how to use com.taobao.weex.utils.WXJsonUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ucar-weex-core   Source File: WXJSObject.java    License: Apache License 2.0 6 votes vote down vote up
public WXJSObject(Object object) {

         if(null == object){
             type= String;
             data = "";
             return;
         }

        data = object;
        if (object instanceof Integer) {
            type = NUMBER;
            data = new Double(((Integer) object).intValue());
        } else if (object instanceof Double) {
            type = NUMBER;
        } else if (object instanceof Float) {
            type = NUMBER;
            data = new Double(((Float) object).intValue());
        } else if (object instanceof String) {
            type = String;
        } else if (object instanceof Object) {
            type = JSON;
            data = WXJsonUtils.fromObjectToJSONString(object,true);
        }
    }
 
Example 2
Source Project: weex-uikit   Source File: WXJSObject.java    License: MIT License 6 votes vote down vote up
public WXJSObject(Object object) {

         if(null == object){
             type= String;
             data = "";
             return;
         }

        data = object;
        if (object instanceof Integer) {
            type = NUMBER;
            data = new Double(((Integer) object).intValue());
        } else if (object instanceof Double) {
            type = NUMBER;
        } else if (object instanceof Float) {
            type = NUMBER;
            data = new Double(((Float) object).intValue());
        } else if (object instanceof String) {
            type = String;
        } else if (object instanceof Object) {
            type = JSON;
            data = WXJsonUtils.fromObjectToJSONString(object,true);
        }
    }
 
Example 3
Source Project: ucar-weex-core   Source File: WXBridgeManager.java    License: Apache License 2.0 5 votes vote down vote up
public void invokeExecJS(String instanceId, String namespace, String function,
                          WXJSObject[] args,boolean logTaskDetail){
  if (WXEnvironment.isApkDebugable()) {
    mLodBuilder.append("callJS >>>> instanceId:").append(instanceId)
            .append("function:").append(function);
    if(logTaskDetail)
      mLodBuilder.append(" tasks:").append(WXJsonUtils.fromObjectToJSONString(args));
    WXLogUtils.d(mLodBuilder.substring(0));
    mLodBuilder.setLength(0);
  }
  mWXBridge.execJS(instanceId, namespace, function, args);
}
 
Example 4
Source Project: ucar-weex-core   Source File: WXTimerModule.java    License: Apache License 2.0 5 votes vote down vote up
private WXJSObject[] createTimerArgs(int instanceId, int funcId, boolean keepAlive) {
  ArrayList<Object> argsList = new ArrayList<>();
  argsList.add(funcId);
  argsList.add(new HashMap<>());
  argsList.add(keepAlive);
  WXHashMap<String, Object> task = new WXHashMap<>();
  task.put(KEY_METHOD, METHOD_CALLBACK);
  task.put(KEY_ARGS, argsList);
  Object[] tasks = {task};
  return new WXJSObject[]{
      new WXJSObject(WXJSObject.String, String.valueOf(instanceId)),
      new WXJSObject(WXJSObject.JSON,
                     WXJsonUtils.fromObjectToJSONString(tasks))};
}
 
Example 5
Source Project: ucar-weex-core   Source File: WXSDKInstance.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Refresh instance asynchronously.
 * @param data the new data
 */
public void refreshInstance(Map<String, Object> data) {
  if (data == null) {
    return;
  }
  refreshInstance(WXJsonUtils.fromObjectToJSONString(data));
}
 
Example 6
Source Project: weex-uikit   Source File: WXBridgeManager.java    License: MIT License 5 votes vote down vote up
private void invokeExecJS(String instanceId, String namespace, String function,
                          WXJSObject[] args,boolean logTaskDetail){
  if (WXEnvironment.isApkDebugable()) {
    mLodBuilder.append("callJS >>>> instanceId:").append(instanceId)
            .append("function:").append(function);
    if(logTaskDetail)
      mLodBuilder.append(" tasks:").append(WXJsonUtils.fromObjectToJSONString(args));
    WXLogUtils.d(mLodBuilder.substring(0));
    mLodBuilder.setLength(0);
  }
  mWXBridge.execJS(instanceId, namespace, function, args);
}
 
Example 7
Source Project: weex-uikit   Source File: WXBridgeManager.java    License: MIT License 5 votes vote down vote up
private WXJSObject[] createTimerArgs(int instanceId, int funcId, boolean keepAlive) {
  ArrayList<Object> argsList = new ArrayList<>();
  argsList.add(funcId);
  argsList.add(new HashMap<>());
  argsList.add(keepAlive);
  WXHashMap<String, Object> task = new WXHashMap<>();
  task.put(KEY_METHOD, METHOD_CALLBACK);
  task.put(KEY_ARGS, argsList);
  Object[] tasks={task};
  return new WXJSObject[]{
      new WXJSObject(WXJSObject.String, String.valueOf(instanceId)),
      new WXJSObject(WXJSObject.JSON,
                     WXJsonUtils.fromObjectToJSONString(tasks))};
}
 
Example 8
Source Project: weex-uikit   Source File: WXSDKInstance.java    License: MIT License 5 votes vote down vote up
/**
 * Refresh instance asynchronously.
 * @param data the new data
 */
public void refreshInstance(Map<String, Object> data) {
  if (data == null) {
    return;
  }
  refreshInstance(WXJsonUtils.fromObjectToJSONString(data));
}
 
Example 9
Source Project: weex   Source File: WXSDKInstance.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Refresh instance asynchronously.
 * @param data the new data
 */
public void refreshInstance(Map<String, Object> data) {
  if (data == null) {
    return;
  }
  refreshInstance(WXJsonUtils.fromObjectToJSONString(data));
}