com.taobao.weex.utils.WXJsonUtils Java Examples

The following examples show how to use com.taobao.weex.utils.WXJsonUtils. 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 File: WXJSObject.java    From ucar-weex-core with 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 File: WXJSObject.java    From weex-uikit with 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 File: WXBridgeManager.java    From ucar-weex-core with 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 File: WXTimerModule.java    From ucar-weex-core with 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 File: WXSDKInstance.java    From ucar-weex-core with 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 File: WXBridgeManager.java    From weex-uikit with 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 File: WXBridgeManager.java    From weex-uikit with 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 File: WXSDKInstance.java    From weex-uikit with 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 File: WXSDKInstance.java    From weex with 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));
}