Examples of Json


Examples of cc.plural.jsonij.JSON

        return resultObject;
    }

    public Object marshalJSONDocument(InputStream stream, Class<?> objectClass) throws JSONMarshalerException {
        JSON json;
        try {
            json = JSON.parse(stream);
        } catch (ParserException ex) {
            throw new JSONMarshalerException("", ex);
        } catch (IOException ex) {
View Full Code Here

Examples of com.alibaba.fastjson.JSON

public class Bug_7 extends TestCase {

    public void test_floatArray() throws Exception {
        float[] a = new float[] { 1, 2 };
        String text = JSON.toJSONString(a);
        JSON json = (JSON) JSON.parse(text);
        Assert.assertEquals("[1.0,2.0]", json.toJSONString());
    }
View Full Code Here

Examples of com.antiaction.common.json.annotation.JSON

    return json_om;
  }

  protected JSONObjectMapping mapClass(Class<?> clazz) throws JSONException {
    JSONObjectFieldMapping json_fm;
    JSON json;
    JSONIgnore ignore;

    JSONObjectMapping json_om = JSONObjectMapping.getObjectMapping();
    classMappings.put( clazz.getName(), json_om );

    Constructor<?> constructor = null;
    try {
      constructor = clazz.getConstructor( zeroArgsParameterTypes );
    }
    catch (NoSuchMethodException e) {
    }
    if ( constructor == null ) {
      throw new JSONException( clazz.getName() + " does not have a zero argument constructor!" );
    }

    json = clazz.getAnnotation( JSON.class );
    if ( json != null ) {
      String[] ignores = json.ignore();
      for ( int i=0; i<ignores.length; ++i) {
        json_om.ignore.add( ignores[ i ] );
      }
      String [] nullables = json.nullable();
      for ( int i=0; i<nullables.length; ++i ) {
        json_om.nullableSet.add( nullables[ i ] );
      }
      String[] nullValues = json.nullValues();
      for ( int i=0; i<nullValues.length; ++i ) {
        json_om.nullValuesSet.add( nullValues[ i ] );
      }
    }
View Full Code Here

Examples of com.badlogic.gdx.utils.Json

  }

  protected Json getJsonLoader (final FileHandle skinFile) {
    final Skin skin = this;

    Json json = new Json();
    json.setTypeName(null);
    json.setUsePrototypes(false);

    class AliasSerializer implements Serializer {
      final ObjectMap<String, ?> map;

      public AliasSerializer (ObjectMap<String, ?> map) {
        this.map = map;
      }

      public void write (Json json, Object object, Class valueType) {
        for (Entry<String, ?> entry : map.entries()) {
          if (entry.value.equals(object)) {
            json.writeValue(entry.key);
            return;
          }
        }
        throw new SerializationException(object.getClass().getSimpleName() + " not found: " + object);
      }

      public Object read (Json json, Object jsonData, Class type) {
        String name = (String)jsonData;
        Object object = map.get(name);
        if (object == null) {
          ObjectMap<String, Object> regions = data.resources.get(TextureRegion.class);
          if (regions != null) {
            object = regions.get(name);
            if (object != null) object = new NinePatch((TextureRegion)object)
          }
          if (object == null)
            throw new SerializationException("Skin has a " + type.getSimpleName()
              + " that could not be found in the resources: " + jsonData);
        }
        return object;
      }
    }

    json.setSerializer(Skin.class, new Serializer<Skin>() {
      public void write (Json json, Skin skin, Class valueType) {
        json.writeObjectStart();
        json.writeValue("resources", skin.data.resources);
        for (Entry<Class, ObjectMap<String, Object>> entry : data.resources.entries())
          json.setSerializer(entry.key, new AliasSerializer(entry.value));
        json.writeField(skin, "styles");
        json.writeObjectEnd();
      }

      public Skin read (Json json, Object jsonData, Class ignored) {
        ObjectMap map = (ObjectMap)jsonData;
        readTypeMap(json, (ObjectMap)map.get("resources"), true);
        for (Entry<Class, ObjectMap<String, Object>> entry : data.resources.entries())
          json.setSerializer(entry.key, new AliasSerializer(entry.value));
        readTypeMap(json, (ObjectMap)map.get("styles"), false);
        return skin;
      }

      private void readTypeMap (Json json, ObjectMap<String, ObjectMap> typeToValueMap, boolean isResource) {
        if (typeToValueMap == null)
          throw new SerializationException("Skin file is missing a \"" + (isResource ? "resources" : "styles")
            + "\" section.");
        for (Entry<String, ObjectMap> typeEntry : typeToValueMap.entries()) {
          Class type;
          try {
            type = Class.forName(typeEntry.key);
          } catch (ClassNotFoundException ex) {
            throw new SerializationException(ex);
          }
          ObjectMap<String, ObjectMap> valueMap = (ObjectMap)typeEntry.value;
          for (Entry<String, ObjectMap> valueEntry : valueMap.entries()) {
            try {
              if (isResource)
                addResource(valueEntry.key, json.readValue(type, valueEntry.value));
              else
                addStyle(valueEntry.key, json.readValue(type, valueEntry.value));
            } catch (Exception ex) {
              throw new SerializationException("Error reading " + type.getSimpleName() + ": " + valueEntry.key, ex);
            }
          }
        }
      }
    });

    json.setSerializer(TextureRegion.class, new Serializer<TextureRegion>() {
      public void write (Json json, TextureRegion region, Class valueType) {
        json.writeObjectStart();
        json.writeValue("x", region.getRegionX());
        json.writeValue("y", region.getRegionY());
        json.writeValue("width", region.getRegionWidth());
        json.writeValue("height", region.getRegionHeight());
        json.writeObjectEnd();
      }

      public TextureRegion read (Json json, Object jsonData, Class type) {
        int x = json.readValue("x", int.class, jsonData);
        int y = json.readValue("y", int.class, jsonData);
        int width = json.readValue("width", int.class, jsonData);
        int height = json.readValue("height", int.class, jsonData);
        return new TextureRegion(skin.data.texture, x, y, width, height);
      }
    });

    json.setSerializer(BitmapFont.class, new Serializer<BitmapFont>() {
      public void write (Json json, BitmapFont font, Class valueType) {
        json.writeValue(font.getData().getFontFile().toString().replace('\\', '/'));
      }

      public BitmapFont read (Json json, Object jsonData, Class type) {
        String path = json.readValue(String.class, jsonData);
        FileHandle file = skinFile.parent().child(path);
        if (!file.exists()) file = Gdx.files.internal(path);
        return new BitmapFont(file, false);
      }
    });

    json.setSerializer(NinePatch.class, new Serializer<NinePatch>() {
      public void write (Json json, NinePatch ninePatch, Class valueType) {
        json.writeValue(ninePatch.getPatches());
      }

      public NinePatch read (Json json, Object jsonData, Class type) {
        return new NinePatch(json.readValue(TextureRegion[].class, jsonData));
      }
    });

    return json;
  }
View Full Code Here

Examples of com.citrix.netscaler.nitro.resource.base.Json

   * nitro_service class constructor specifying ip.
   * @param ip Ipadress of the netscaler on which configuration is to be run.
   */
  public nitro_service(String ip) throws nitro_exception
  {
    this(ip, new Json(),"http");
  }
View Full Code Here

Examples of com.citrix.sdx.nitro.resource.base.Json

   * nitro_service class constructor specifying ip.
   * @param ip IPAddress of the NetScaler SDX on which configuration is to be run.
   */
  public nitro_service(String ip) throws nitro_exception
  {
    this(ip, new Json(), "http");
  }
View Full Code Here

Examples of com.esotericsoftware.jsonbeans.Json

  public static boolean isMacOSX = false;
  public static boolean isLinux = false;
 
  public static void main(String[] args) throws IOException{
    arguments = new Arguments(args);
    Json json = new Json();
    json.setOutputType(OutputType.json);
   
    determineOS();
   
    System.out.println("Jar Wrapper Version " + version);
    System.out.println("*********");
   
    /*
    BundlerConfig config = new BundlerConfig();
    config.defaults();
    String configFile = json.prettyPrint(config);
    saveConfigFile(configFile);
    */
   
    System.out.print("Loading config file ... ");
   
    File configFile;
   
    if(arguments.has("-config")){
      configFile = new File(arguments.get("-config"));
    }
    else {
      configFile = new File("config/config.json");
    }
   
    if(!configFile.exists()){
      System.out.println("Can't find the supplied config file, or the default file.");
      System.exit(0);
    }
    else {
      String configContent = readFile(configFile);
      config = json.fromJson(BundlerConfig.class, configContent);
    }
   
    if(config == null){
      System.out.println("Something went wrong while loading the config file. Abort.");
      System.exit(0);
View Full Code Here

Examples of com.googlecode.jsonplugin.annotations.JSON

                } else
                    baseAccessor = accessor;

                if (baseAccessor != null) {

                    JSON json = baseAccessor.getAnnotation(JSON.class);
                    if (json != null) {
                        if (!json.serialize())
                            continue;
                        else if (json.name().length() > 0)
                            name = json.name();
                    }

                    //ignore "class" and others
                    if (this.shouldExcludeProperty(clazz, prop)) {
                        continue;
View Full Code Here

Examples of com.ibm.commons.util.io.json.parser.Json

   * @throws JsonException
   * @ibm-api
   */
  public static boolean isJson(String json) {
    try {
      Json parser = getParser(JsonEmptyFactory.instance,new java.io.StringReader(json));
      parser.parseJson();
      return true;
    } catch(Throwable ex) {
      return false;
    }
  }
View Full Code Here

Examples of com.yammer.dropwizard.json.Json

public class TodoMapper implements ResultSetMapper<Todo> {

  @Override
  public Todo map(int i, ResultSet resultSet, StatementContext statementContext)
      throws SQLException {
    Json json = new Json();
    try {
      return json.readValue(resultSet.getString("json"), Todo.class);

    } catch (IOException e) {
      throw propagate(e);
    }
  }
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.