package com.kmecpp.jflame;

import java.util.Map;

import com.kmecpp.jflame.value.JsonArray;
import com.kmecpp.jflame.value.JsonBoolean;
import com.kmecpp.jflame.value.JsonNull;
import com.kmecpp.jflame.value.JsonNumber;
import com.kmecpp.jflame.value.JsonObject;
import com.kmecpp.jflame.value.JsonString;

public final class Json {

	//Literals
	public static final JsonNull NULL = JsonNull.getInstance();
	public static final JsonBoolean TRUE = new JsonBoolean(true);
	public static final JsonBoolean FALSE = new JsonBoolean(false);

	private Json() {
	}

	/**
	 * Parses the given JSON string and returns a {@link JsonValue} that
	 * represents the data
	 * 
	 * @param json
	 *            the JSON string to parse
	 * @return a {@link JsonValue} representing the given string
	 * @throws InvalidJsonException
	 *             if the string is not valid JSON
	 */
	public static JsonValue parse(String json) throws InvalidJsonException {
		return new JsonParser(json).parse();
	}

	/**
	 * Generates a formatted string from a {@link JsonValue}. To generate a
	 * compressed string, call jsonValue.toString()
	 * 
	 * @param json
	 *            the json object to serialize
	 * @return a formatted String representation of the JSON object
	 */
	public static String generate(JsonValue json) {
		return json.getFormatted();
	}

	//VALUES
	public static JsonArray fromList(Iterable<JsonValue> iterable) {
		return new JsonArray(iterable);
	}

	public static JsonArray fromArray(JsonValue[] array) {
		return new JsonArray(array);
	}

	public static JsonObject fromMap(Map<String, JsonValue> map) {
		return new JsonObject(map);
	}

	public static JsonString fromString(String value) {
		return new JsonString(value);
	}

	public static JsonBoolean fromBoolean(Boolean value) {
		return new JsonBoolean(value);
	}

	public static JsonNumber fromInt(Integer value) {
		return new JsonNumber(value);
	}

	public static JsonNumber fromLong(Long value) {
		return new JsonNumber(value);
	}

	public static JsonNumber fromFloat(Float value) {
		return new JsonNumber(value);
	}

	public static JsonNumber fromDouble(Double value) {
		return new JsonNumber(value);
	}

}

@@ -37,18 +37,126 @@
 ava.
-util.Map;%0A
+io.File;%0Aimport java.io.IOException;%0Aimport java.net.URL;%0Aimport java.util.Map;%0A%0Aimport com.kmecpp.jflame.util.JsonIO;
 %0Aimp
@@ -1430,16 +1430,1085 @@
 ();%0A%09%7D%0A%0A
+%09/**%0A%09 * Reads a %7B@link JsonValue%7D from the given URL%0A%09 * %0A%09 * @param url%0A%09 *            the URL to read from%0A%09 * @return a %7B@link JsonValue%7D representing the text retrieved from the URL%0A%09 * @throws IOException%0A%09 *             if an IOException occurs%0A%09 */%0A%09public static JsonValue readJson(URL url) throws IOException %7B%0A%09%09return parse(JsonIO.read(url));%0A%09%7D%0A%0A%09/**%0A%09 * Writes the given %7B@link JsonValue%7D to the URL%0A%09 * %0A%09 * @param url%0A%09 *            the URL to write to%0A%09 * @param json%0A%09 *            the %7B@link JsonValue%7D to write%0A%09 * @throws IOException%0A%09 *             if an IOException occurs%0A%09 */%0A%09public static void writeJson(URL url, JsonValue json) throws IOException %7B%0A%09%09JsonIO.postUrl(url, json);%0A%09%7D%0A%0A%09/**%0A%09 * Writes the given %7B@link JsonValue%7D to the file%0A%09 * %0A%09 * @param file%0A%09 *            the file to write to%0A%09 * @param json%0A%09 *            the %7B@link JsonValue%7D to write%0A%09 * @throws IOException%0A%09 *             if an IOException occurs%0A%09 */%0A%09public static void writeJson(File file, JsonValue json) throws IOException %7B%0A%09%09JsonIO.writeFile(file, json);%0A%09%7D%0A%0A
 %09//VALUE

Add back some IO methods to Json