Examples of JSONObject


Examples of com.gemstone.org.json.JSONObject

*
*/
public class JsonStringToObjectTransformer {

  public PdxInstance toObject(String json) {
    JSONObject jsonObject = null;
    try {
      jsonObject = new JSONObject(json);
    }
    catch (JSONException e) {
      throw new MessageTransformationException(e.getMessage());
    }
    return JSONFormatter.fromJSON(jsonObject.toString());
  }
View Full Code Here

Examples of com.github.jsonj.JsonObject

public class JsonBuilder {
    private final JsonObject object;

    private JsonBuilder() {
        // use the static methods
        object = new JsonObject();
    }
View Full Code Here

Examples of com.goodow.realtime.json.JsonObject

  public void load(final String id, final Handler<Document> onLoaded,
      final Handler<Model> opt_initializer, final Handler<Error> opt_error) {
    bus.send(Constants.Topic.STORE, Json.createObject().set(Key.ID, id), new Handler<Message<JsonObject>>() {
      @Override
      public void handle(Message<JsonObject> message) {
        JsonObject body = message.body();
        if (!body.has(Key.VERSION)) {
          body.set(Key.VERSION, 0);
        }
        final DocumentBridge bridge =
            new DocumentBridge(SubscribeOnlyStore.this, id, body.getArray(Key.SNAPSHOT),
                               body.getArray(Key.COLLABORATORS), opt_error);
        onLoaded(id, opt_initializer, body.getNumber(Key.VERSION), bridge);
        if (body.getNumber(Key.VERSION) == 0) {
          bridge.createRoot();
          if (opt_initializer != null) {
            Platform.scheduler().handle(opt_initializer, bridge.getDocument().getModel());
          }
        }
View Full Code Here

Examples of com.google.appengine.labs.repackaged.org.json.JSONObject

      surveyJson[listSurveys.size()-1-i][0] = listSurveys.get(i).getId() + "-+" + listSurveys.get(i).getTitle() + "/" + listSurveys.get(i).getDateCreated();
      surveyJson[listSurveys.size()-1-i][1] = listSurveys.get(i).getNarrative();
    }
   
    //���ʾ��������������ʽ��ΪJSON��ʽ   
    JSONObject surveyJsonObject = new JSONObject();
    try {
      surveyJsonObject.put("surveyJson", surveyJson);
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
View Full Code Here

Examples of com.google.appengine.repackaged.org.json.JSONObject

    scanCount = (int) ((9 * scanCount) + (scanCount / time * targetRoundTime)) / 10;
    config.setScanCount(scanCount);
  }

  private Work fetchWork(Config config) throws IOException, JSONException {
    JSONObject getwork = new JSONObject();
    getwork.put("method", "getwork");
    getwork.put("params", new JSONArray());
    getwork.put("id", 0);

    URL url = new URL(config.getJsonRpcServer());

    URLFetchService ufs = URLFetchServiceFactory.getURLFetchService();
    HTTPRequest req = new HTTPRequest(url, HTTPMethod.POST);
    req.setPayload(getwork.toString().getBytes());
    req.addHeader(new HTTPHeader("Authorization", config.getAuth()));

    HTTPResponse resp = ufs.fetch(req);
    String content = new String(resp.getContent());
    if (resp.getResponseCode() != 200) {
      throw new IOException( //
          "fetchWork Error: " + resp.getResponseCode() + " "
              + content);
    }

    JSONObject respwork = new JSONObject(content);
    Object errorP = respwork.get("error");
    if (errorP != JSONObject.NULL) {
      JSONObject error = (JSONObject) errorP;
      throw new IOException( //
          "fetchWork Error: " + error.getString("message") //
              + " (" + error.getInt("code") + ")");
    }
    JSONObject result = respwork.getJSONObject("result");
    Work work = new Work( //
        result.getString("data"), //
        result.getString("hash1"), //
        result.getString("target"), //
        result.getString("midstate"));
    return work;
  }
View Full Code Here

Examples of com.google.gson.JsonObject

      }
      List<DriveInfo> drivesList = (List<DriveInfo>) payload;
      JsonArray drivesJsonArray = new JsonArray();

      for (DriveInfo drive : drivesList) {
         JsonObject driveObject = createDriveRequestJson.apply(drive);
         drivesJsonArray.add(driveObject);
      }

      JsonObject json = new JsonObject();
      json.add("objects", drivesJsonArray);

      request.setPayload(json.toString());
      request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
      return request;
   }
View Full Code Here

Examples of com.google.gwt.dev.jjs.ast.js.JsonObject

    }

    private JField createEnumValueMap(JEnumType type) {
      SourceInfo sourceInfo = type.getSourceInfo().makeChild(
          JavaASTGenerationVisitor.class, "enum value lookup map");
      JsonObject map = new JsonObject(sourceInfo, program.getJavaScriptObject());
      for (JEnumField field : type.getEnumList()) {
        // JSON maps require leading underscores to prevent collisions.
        JStringLiteral key = program.getLiteralString(field.getSourceInfo(),
            "_" + field.getName());
        JFieldRef value = new JFieldRef(sourceInfo, null, field, type);
        map.propInits.add(new JsonObject.JsonPropInit(sourceInfo, key, value));
      }
      JField mapField = program.createField(sourceInfo,
          "enum$map".toCharArray(), type, map.getType(), true,
          Disposition.FINAL);

      // Initialize in clinit.
      JMethodBody clinitBody = (JMethodBody) type.getMethods().get(0).getBody();
      JExpressionStatement assignment = program.createAssignmentStmt(
View Full Code Here

Examples of com.google.gwt.dev.json.JsonObject

            shuttingDown = true;
          } else if (event == flushSentinel) {
            writer.flush();
            flushLatch.countDown();
          } else {
            JsonObject json = event.toJson();
            json.write(writer);
            writer.write('\n');
          }
        }
        // All queued events have been written.
        if (outputFormat.equals(Format.HTML)) {
View Full Code Here

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

            public void onClick(Widget sender) {
                if (!"".equals(textBoxNewMessage.getText())) {
                    JSONArray array = new JSONArray();
                    array.set(0, new JSONString(textBoxNewMessage.getText()));

                    JSONObject container = new JSONObject();
                    container.put("value", array);

                    streamingService.sendMessage(textBoxTopic.getText(), container);
                    textBoxNewMessage.setText("");
                    textBoxNewMessage.setFocus(true);
                }
View Full Code Here

Examples of com.google.gwt.thirdparty.json.JSONObject

public class JsonLogRecordServerUtil {

  public static LogRecord logRecordFromJson(String jsonString)
      throws InvalidJsonLogRecordFormatException {
    try {
      JSONObject lro = new JSONObject(jsonString);
      String level = lro.getString("level");
      String loggerName = lro.getString("loggerName");
      String msg = lro.getString("msg");
      long timestamp = Long.parseLong(lro.getString("timestamp"));
      Throwable thrown = JsonLogRecordThrowable.fromJsonString(lro.getString("thrown"));
      LogRecord lr = new LogRecord(Level.parse(level), msg);
      lr.setLoggerName(loggerName);
      lr.setThrown(thrown);
      lr.setMillis(timestamp);
      return lr;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.