Search in sources :

Example 6 with JsonStreamParser

use of com.google.gson.JsonStreamParser in project commons by twitter.

the class TTextProtocol method readMapBegin.

@Override
public TMap readMapBegin() throws TException {
    getCurrentContext().read();
    JsonElement curElem = getCurrentContext().getCurrentChild();
    if (getCurrentContext().isMapKey()) {
        curElem = new JsonStreamParser(curElem.getAsString()).next();
    }
    if (!curElem.isJsonObject()) {
        throw new TException("Expected JSON Object!");
    }
    pushContext(new MapContext(curElem.getAsJsonObject()));
    return new TMap(UNUSED_TYPE, UNUSED_TYPE, curElem.getAsJsonObject().entrySet().size());
}
Also used : TException(org.apache.thrift.TException) JsonElement(com.google.gson.JsonElement) JsonStreamParser(com.google.gson.JsonStreamParser) TMap(org.apache.thrift.protocol.TMap)

Aggregations

JsonStreamParser (com.google.gson.JsonStreamParser)6 JsonElement (com.google.gson.JsonElement)4 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)3 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 TException (org.apache.thrift.TException)2 Gson (com.google.gson.Gson)1 JsonParseException (com.google.gson.JsonParseException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Produces (javax.ws.rs.Produces)1 TMap (org.apache.thrift.protocol.TMap)1 MCRCategoryID (org.mycore.datamodel.classifications2.MCRCategoryID)1 MCRJSONCategory (org.mycore.frontend.classeditor.json.MCRJSONCategory)1 MCRRestrictedAccess (org.mycore.frontend.jersey.filter.access.MCRRestrictedAccess)1 MCRNavigation (org.mycore.wcms2.datamodel.MCRNavigation)1