// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java
// public abstract class DeserializationContext {
// 
//     private final ContainerFactoryManager containerFactoryManager;
// 
//     public DeserializationContext(ContainerFactoryManager containerFactoryManager) {
//         this.containerFactoryManager = containerFactoryManager;
//     }
// 
//     public <C extends Collection> C getContainerInstance(Class<C> type) {
//         final Factory<C> factory = containerFactoryManager.getFactory(type);
//         if (factory == null)
//             throw new UnableToDeserializeException("Could not get container instance because there's no factory " +
//                     "registered in the requestor.");
//         return factory.get();
//     }
// 
//     protected ContainerFactoryManager getContainerFactoryManager() {
//         return containerFactoryManager;
//     }
// }
// 
// Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java
// public abstract class SerializationContext {
// }
// 
// Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java
// public class UnableToDeserializeException extends SerializationException {
// 
//     public UnableToDeserializeException() {
//     }
// 
//     public UnableToDeserializeException(String s) {
//         super(s);
//     }
// 
//     public UnableToDeserializeException(String s, Throwable throwable) {
//         super(s, throwable);
//     }
// }


import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsonUtils;
import java.util.Collection;
import org.turbogwt.core.util.client.Overlays;
import org.turbogwt.net.serialization.client.DeserializationContext;
import org.turbogwt.net.serialization.client.SerializationContext;
import org.turbogwt.net.serialization.client.UnableToDeserializeException;
    public String serialize(T t, SerializationContext context) {
        final JsonRecordWriter writer = JsonRecordWriter.create();
        writeJson(t, writer, context);
        return Overlays.stringify(writer);
    }

    /**
     * Checks if the serialized content is a JSON Object.
     *
     * @param text Serialized response
     *
     * @return {@code true} if argument is a JSON object, {@code false} otherwise
     */
    protected boolean isObject(String text) {
        final String trim = text.trim();
        return trim.startsWith("{") && trim.endsWith("}");
    }

    /**
     * Performs evaluation of serialized response obeying the #useSafeEval configuration.
     * <p/>
     *
     * If #useSafeEval is {@code true} then the eval is performed using {@link JsonUtils#safeEval},
     * otherwise then content will be loosely evaluated by {@link JsonUtils#unsafeEval}.
     *
     * @param response The serialized content
     *
     * @return The converted JavaScriptObject
     */
    protected JavaScriptObject eval(String response) {
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java
// public abstract class DeserializationContext {
// 
//     private final ContainerFactoryManager containerFactoryManager;
// 
//     public DeserializationContext(ContainerFactoryManager containerFactoryManager) {
//         this.containerFactoryManager = containerFactoryManager;
//     }
// 
//     public <C extends Collection> C getContainerInstance(Class<C> type) {
//         final Factory<C> factory = containerFactoryManager.getFactory(type);
//         if (factory == null)
//             throw new UnableToDeserializeException("Could not get container instance because there's no factory " +
//                     "registered in the requestor.");
//         return factory.get();
//     }
// 
//     protected ContainerFactoryManager getContainerFactoryManager() {
//         return containerFactoryManager;
//     }
// }
// 
// Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java
// public abstract class SerializationContext {
// }
// 
// Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java
// public class UnableToDeserializeException extends SerializationException {
// 
//     public UnableToDeserializeException() {
//     }
// 
//     public UnableToDeserializeException(String s) {
//         super(s);
//     }
// 
//     public UnableToDeserializeException(String s, Throwable throwable) {
//         super(s, throwable);
//     }
// }


// Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonObjectSerdes.java
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsonUtils;
import java.util.Collection;
import org.turbogwt.core.util.client.Overlays;
import org.turbogwt.net.serialization.client.DeserializationContext;
import org.turbogwt.net.serialization.client.SerializationContext;
import org.turbogwt.net.serialization.client.UnableToDeserializeException;

    public String serialize(T t, SerializationContext context) {
        final JsonRecordWriter writer = JsonRecordWriter.create();
        writeJson(t, writer, context);
        return Overlays.stringify(writer);
    }

    /**
     * Checks if the serialized content is a JSON Object.
     *
     * @param text Serialized response
     *
     * @return {@code true} if argument is a JSON object, {@code false} otherwise
     */
    protected boolean isObject(String text) {
        final String trim = text.trim();
        return trim.startsWith("{") && trim.endsWith("}");
    }

    /**
     * Performs evaluation of serialized response obeying the #useSafeEval configuration.
     * <p/>
     *
     * If #useSafeEval is {@code true} then the eval is performed using {@link JsonUtils#safeEval},
     * otherwise then content will be loosely evaluated by {@link JsonUtils#unsafeEval}.
     *
     * @param response The serialized content
     *
     * @return The converted JavaScriptObject
     */
    protected JavaScriptObject eval(String response) {
        return useSafeEval() ? JsonUtils.safeEval(response) : JsonUtils.unsafeEval(response);