Package net.arnx.jsonic

Examples of net.arnx.jsonic.JSON.format()


      Map<String, String> map = new HashMap<String, String>();
      Enumeration<String> e =  cast(servletConfig.getInitParameterNames());
      while (e.hasMoreElements()) {
        map.put(e.nextElement(), servletConfig.getInitParameter(e.nextElement()));
      }
      configText = json.format(map);
    }
   
    try {
      config = json.parse(configText, Config.class);
      if (config.container == null) config.container = Container.class;
View Full Code Here


    Writer writer = response.getWriter();
   
    Object target = (isBatch) ? responseList : responseList.get(0);
    json.setContext(target);
    json.setPrettyPrint(container.isDebugMode());
    json.format(target, writer);
  }
 
  @Override
  public void destroy() {
    container.destory();
View Full Code Here

        m.setDoubleAttr(11.1);
        String json = WrapperAttrsModelMeta.get().modelToJson(m);
        System.out.println(json);
        JSON j = new JSON();
        j.setSuppressNull(true);
        System.out.println(j.format(m));
        Assert.assertEquals("{\"booleanAttr\":true,\"doubleAttr\":11.1"
            + ",\"floatAttr\":1.1,\"integerAttr\":1000"
            + ",\"longAttr\":10000,\"shortAttr\":100}", json);
    }
View Full Code Here

        String json = OtherJavaTypeListAttrsModelMeta.get().modelToJson(m);
        System.out.println(json);
        JSON j = new JSON();
        j.setSuppressNull(true);
        System.out.println(j.format(m));

        Assert.assertEquals("{\"dateListAttr\":[1289441471000,1292080332000]"
            + ",\"enumListAttr\":[\"Sun\",\"Mon\",\"Tue\"]"
            + ",\"stringListAttr\":[\"hello\",\"world\"]}", json);
    }
View Full Code Here

        String json = m.modelToJson(model);
        System.out.println(json);
        JSON j = new JSON();
        j.setSuppressNull(true);
        System.out.println(j.format(model));

        Assert.assertEquals(
            "{\"booleanSetAttr\":[false,true],\"doubleSetAttr\":[9.9,8.8,7.7]"
                + ",\"floatSetAttr\":[8.8,7.7,9.9],\"integerSetAttr\":[7,8,9]"
                + ",\"longSetAttr\":[7,8,9],\"shortSetAttr\":[7,8,9]}",
View Full Code Here

        String json = meta.modelToJson(m);
        System.out.println(json);
        JSON j = new JSON();
        j.setSuppressNull(true);
        System.out.println(j.format(m));

        Assert
            .assertEquals(
                "{\"dateAttr\":1289441471000,\"encryptedStringAttr\":\"mMB4qZAgtBKJq0d1LBGTCA==\""
                    + ",\"enumAttr\":\"Sun\",\"stringAttr\":\"hello\"}",
View Full Code Here

        String json = m.modelToJson(model);
        System.out.println(json);
        JSON j = new JSON();
        j.setSuppressNull(true);
        System.out.println(j.format(model));

        Assert
            .assertEquals(
                "{\"booleanSortedSetAttr\":[false,true],\"doubleSortedSetAttr\":[7.7,8.8,9.9]"
                    + ",\"floatSortedSetAttr\":[7.7,8.8,9.9],\"integerSortedSetAttr\":[7,8,9]"
View Full Code Here

        m.setDoubleAttr(11.1);
        String json = PrimitiveAttrsModelMeta.get().modelToJson(m);
        System.out.println(json);
        JSON j = new JSON();
        j.setSuppressNull(true);
        System.out.println(j.format(m));
        Assert.assertEquals("{\"booleanAttr\":true,\"doubleAttr\":11.1"
            + ",\"floatAttr\":1.1,\"intAttr\":1000"
            + ",\"longAttr\":10000,\"shortAttr\":100}", json);
    }
View Full Code Here

        String json = AppEngineTypeListAttrsModelMeta.get().modelToJson(m);
        System.out.println(json);
        JSON j = new JSON();
        j.setSuppressNull(true);
        System.out.println(j.format(m));
        // JSON.decode(json);

        Assert
            .assertEquals(
                "{\"blobKeyListAttr\":[\"lkwejl2k3jrksl\",\"kaekl23joij\"]"
View Full Code Here

        model.setDoubleListAttr(Arrays.asList(9.9, 8.8, 7.7));
        String json = m.modelToJson(model);
        System.out.println(json);
        JSON j = new JSON();
        j.setSuppressNull(true);
        System.out.println(j.format(model));
        Assert
            .assertEquals(
                "{\"booleanListAttr\":[true,false,true],\"doubleListAttr\":[9.9,8.8,7.7],\"floatListAttr\":[9.9,8.8,7.7]"
                    + ",\"integerListAttr\":[9,8,7],\"longListAttr\":[9,8,7]"
                    + ",\"shortListAttr\":[9,8,7]}",
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.