Package org.quickconnectfamily.json

Examples of org.quickconnectfamily.json.JSONInputStream


    String aJSONString = "{\"aNumber\":\"16.5\",\"stringOne\":\"Some sort of string\",\"20\":\"some other stuff\",\"aTester\":{\"stringAtt\":\"hello\",\"doubleAtt\":\"-4.5\",\"doubleObjAtt\":\"1000.567789\",\"listAtt\":[\"7\",\"hello there from list\"],\"parentString\":\"In The Parent\"}}\n";

    byte[] byteArray = aJSONString.getBytes();
    ByteArrayInputStream theByteStream = new ByteArrayInputStream(byteArray);
    JSONInputStream aJSONInputStream = new JSONInputStream(theByteStream);
    Class<?> theJSONInputStreamClass = aJSONInputStream.getClass();

      try {
      Field theParserField = theJSONInputStreamClass.getDeclaredField("aParser");
      theParserField.setAccessible(true);
      assertNotNull(theParserField.get(aJSONInputStream));
View Full Code Here


    try {
      PrintWriter fileWriter = new PrintWriter(new FileOutputStream(multiObjectFile));
      fileWriter.println("{\"name\":\"Bob\",\"age\":27}[7,16,0 -4]");
      fileWriter.flush();

      JSONInputStream jsonIn = new JSONInputStream(new FileInputStream(multiObjectFile));

      /*
       * Read the first object from the file
       */
      Object aPossibleMap = jsonIn.readObject();
      assertEquals(HashMap.class, aPossibleMap.getClass());
      HashMap aMap = (HashMap)aPossibleMap;
      assertEquals("Bob", aMap.get("name"));
      assertEquals((long)27, aMap.get("age"));
     
      /*
       * Test if a second entry be read correctly?
       */
      Object aPossibleArrayList = jsonIn.readObject();
      assertEquals(ArrayList.class, aPossibleArrayList.getClass());
      ArrayList anArrayList = (ArrayList)aPossibleArrayList;
     
     
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.quickconnectfamily.json.JSONInputStream

Copyright © 2018 www.massapicom. 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.