@@ -0,0 +1,2525 @@
+/*%0A * Copyright 2014 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage net.kuujo.vertigo.util;%0A%0Aimport com.fasterxml.jackson.annotation.JsonAutoDetect;%0Aimport com.fasterxml.jackson.annotation.JsonIgnoreProperties;%0Aimport com.fasterxml.jackson.annotation.JsonInclude;%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport io.vertx.core.json.JsonObject;%0Aimport net.kuujo.vertigo.VertigoException;%0A%0Aimport java.io.IOException;%0A%0A/**%0A * JSON utilities.%0A *%0A * @author %3Ca href=%22http://github.com/kuujo%22%3EJordan Halterman%3C/a%3E%0A */%0Apublic final class Json %7B%0A  private static final ObjectMapper mapper = new ObjectMapper();%0A%0A  /**%0A   * JSON serializable interface.%0A   */%0A  @JsonIgnoreProperties(ignoreUnknown=true)%0A  @JsonInclude(JsonInclude.Include.ALWAYS)%0A  @JsonAutoDetect(%0A    creatorVisibility= JsonAutoDetect.Visibility.NONE,%0A    fieldVisibility=JsonAutoDetect.Visibility.ANY,%0A    getterVisibility=JsonAutoDetect.Visibility.NONE,%0A    isGetterVisibility=JsonAutoDetect.Visibility.NONE,%0A    setterVisibility=JsonAutoDetect.Visibility.NONE%0A  )%0A  public static interface Serializable %7B%0A  %7D%0A%0A  /**%0A   * Serializes an object to JSON.%0A   *%0A   * @param object The object to serialize.%0A   * @param %3CT%3E The serializable type.%0A   * @return The serialized object.%0A   */%0A  public static %3CT extends Json.Serializable%3E JsonObject serialize(T object) %7B%0A    try %7B%0A      return new JsonObject(mapper.writeValueAsString(object));%0A    %7D catch (IOException e) %7B%0A      throw new VertigoException(e);%0A    %7D%0A  %7D%0A%0A  /**%0A   * Deserializes an object from JSON.%0A   *%0A   * @param json The JSON from which to deserialize the object.%0A   * @param type The object type to deserialize.%0A   * @param %3CT%3E The deserialized object type.%0A   * @return The deserialized object.%0A   */%0A  public static %3CT extends Json.Serializable%3E T deserialize(JsonObject json, Class%3CT%3E type) %7B%0A    try %7B%0A      return mapper.readValue(json.encode(), type);%0A    %7D catch (IOException e) %7B%0A      throw new VertigoException(e);%0A    %7D%0A  %7D%0A%0A%7D%0A

Add JSON serializion support for definitions and contexts.