public static void dispatch(DocumentBuilder builder, String name, Object o) throws JSONException
	{
		if (o == null)
			return;

		if (o == JSONObject.NULL) {
			builder.putNull(name);
		} else if (o instanceof String) {
			String s = o.toString();
			if (s.length() > Short.MAX_VALUE)
				s = s.substring(0, Short.MAX_VALUE);
			builder.put(name, s);
		} else if (o instanceof Boolean) {
			builder.put(name, (Boolean) o);
		} else if (o instanceof Integer) {
			builder.put(name, (Integer) o);
		} else if (o instanceof JSONObject) {
			builder.tree(name);
			translate(builder, (JSONObject) o);
			builder.pop();
		} else if (o instanceof JSONArray) {
			builder.tree(name);
			translate(builder, (JSONArray) o);
			builder.pop();
		} else {
			System.err.println("not handeled class: " + o.getClass().getCanonicalName());
			System.out.println(o);
		}
	}