Package com.orientechnologies.orient.core.record.impl

Examples of com.orientechnologies.orient.core.record.impl.ODocument.toJSON()


    map1.put("map2", (HashMap<?, ?>) map2);

    final Map<String, HashMap<?, ?>> map3 = new HashMap<String, HashMap<?, ?>>();
    map2.put("map3", (HashMap<?, ?>) map3);

    String json = newDoc.toJSON();
    ODocument loadedDoc = new ODocument().fromJSON(json);

    Assert.assertTrue(newDoc.hasSameContentOf(loadedDoc));

    Assert.assertTrue(loadedDoc.containsField("map1"));
View Full Code Here


      list.add(doc1);
    }
    doc.field("out", list);
    String json = doc.toJSON();
    ODocument newDoc = new ODocument().fromJSON(json);
    Assert.assertEquals(newDoc.toJSON(), json);
    Assert.assertTrue(newDoc.hasSameContentOf(doc));

    doc = new ODocument();
    doc.field("string", "STRING_VALUE");
    Map<String, ODocument> docMap = new HashMap<String, ODocument>();
View Full Code Here

  public void testSpaces() {
    ODocument doc = new ODocument();
    String test = "{" + "\"embedded\": {" + "\"second_embedded\":  {" + "\"text\":\"this is a test\"" + "}" + "}" + "}";
    doc.fromJSON(test);
    Assert.assertTrue(doc.toJSON("fetchPlan:*:0,rid").indexOf("this is a test") > -1);
  }

  public void testEscaping() {
    ODocument doc = new ODocument();
    String s = "{\"name\": \"test\", \"nested\": { \"key\": \"value\", \"anotherKey\": 123 }, \"deep\": {\"deeper\": { \"k\": \"v\",\"quotes\": \"\\\"\\\",\\\"oops\\\":\\\"123\\\"\", \"likeJson\": \"[1,2,3]\",\"spaces\": \"value with spaces\"}}}";
View Full Code Here

    ODocument doc = new ODocument();
    String s = "{\"name\": \"test\", \"nested\": { \"key\": \"value\", \"anotherKey\": 123 }, \"deep\": {\"deeper\": { \"k\": \"v\",\"quotes\": \"\\\"\\\",\\\"oops\\\":\\\"123\\\"\", \"likeJson\": \"[1,2,3]\",\"spaces\": \"value with spaces\"}}}";
    doc.fromJSON(s);
    Assert.assertEquals(doc.field("deep[deeper][quotes]"), "\"\",\"oops\":\"123\"");

    String res = doc.toJSON();

    // LOOK FOR "quotes": \"\",\"oops\":\"123\"
    Assert.assertTrue(res.contains("\"quotes\":\"\\\"\\\",\\\"oops\\\":\\\"123\\\"\""));
  }
View Full Code Here

  public void testDates() {
    Date now = new Date(1350518475000l);

    ODocument doc = new ODocument();
    doc.field("date", now);
    String json = doc.toJSON();

    ODocument unmarshalled = new ODocument().fromJSON(json);
    Assert.assertEquals(unmarshalled.field("date"), now);
  }
View Full Code Here

    for (int i = 0; i < THREADS; ++i)
      Assert.assertEquals(doc2.field(ops[i].threadName), ops[i].fieldValue, ops[i].threadName);

    System.out.println("RESULT doc 2:");
    System.out.println(doc2.toJSON());

    for (int i = 0; i < THREADS; ++i)
      databases[i].close();

    System.out.println("Test completed in " + (System.currentTimeMillis() - startedOn));
View Full Code Here

      //log("Person count: {}", db.countClass("Person"));

      ODocument doc = createPerson(db);
      log("Document: {}", doc);
      log("Document size: {}", doc.getSize());
      log("Document (default) JSON: {}", doc.toJSON());
      log("Document (custom) JSON: {}", doc.toJSON("rid,version,class,type,attribSameRow,keepTypes,alwaysFetchEmbedded,prettyPrint,fetchPlan:*:0"));

      log("DB size: {}", db.getSize());
      log("Person count: {}", db.countClass("Person"));
    }
View Full Code Here

      ODocument doc = createPerson(db);
      log("Document: {}", doc);
      log("Document size: {}", doc.getSize());
      log("Document (default) JSON: {}", doc.toJSON());
      log("Document (custom) JSON: {}", doc.toJSON("rid,version,class,type,attribSameRow,keepTypes,alwaysFetchEmbedded,prettyPrint,fetchPlan:*:0"));

      log("DB size: {}", db.getSize());
      log("Person count: {}", db.countClass("Person"));
    }

View Full Code Here

                            ODocument coll = CollectionService.create(COLL);
                            ObjectNode node = Json.mapper().createObjectNode();
                            node.put("ciao","ciao");
                            DbHelper.requestTransaction();
                            ODocument doc = DocumentService.create(COLL, node);
                            Logger.debug("**************************************************: "+doc.toJSON("fetchPlan:_links:0"));
                            String rid = DocumentService.getRidByString(doc.field("id"), true);
                            DocumentService.grantPermissionToRole(COLL, rid, Permissions.ALLOW_READ, DefaultRoles.ANONYMOUS_USER.toString());
                            DbHelper.commitTransaction();
                           Logger.debug("**************************************************A:  "+doc.toJSON("fetchPlan:_links:0"));
                        } catch (Throwable e) {
View Full Code Here

                            ODocument doc = DocumentService.create(COLL, node);
                            Logger.debug("**************************************************: "+doc.toJSON("fetchPlan:_links:0"));
                            String rid = DocumentService.getRidByString(doc.field("id"), true);
                            DocumentService.grantPermissionToRole(COLL, rid, Permissions.ALLOW_READ, DefaultRoles.ANONYMOUS_USER.toString());
                            DbHelper.commitTransaction();
                           Logger.debug("**************************************************A:  "+doc.toJSON("fetchPlan:_links:0"));
                        } catch (Throwable e) {
                            Logger.debug(ExceptionUtils.getFullStackTrace(e));
                            fail(ExceptionUtils.getFullStackTrace(e));
                            DbHelper.rollbackTransaction();
                        } finally {
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.