Package com.google.gson

Examples of com.google.gson.JsonObject.entrySet()


      if (null != metadata) {
        json.getAsJsonObject().remove("metadata");
      }
      DocumentPojo doc = BaseDbPojo.getDefaultBuilder().create().fromJson(json, DocumentPojo.class)
      if (null != metadata) {       
        for (Entry<String, JsonElement> entry: metadata.entrySet()) {
          if (entry.getValue().isJsonArray()) {
            doc.addToMetadata(entry.getKey(), MongoDbUtil.encodeArray(entry.getValue().getAsJsonArray()).toArray());
          }
          else {
            BasicDBList dbl = new BasicDBList();
View Full Code Here


      return encodeArray(from.getAsJsonArray());
    }//TESTED
    else if (from.isJsonObject()) { // Object
      JsonObject obj = from.getAsJsonObject();
      // Check for OID/Date:
      if (1 == obj.entrySet().size()) {
        if (obj.has("$date")) {
          try {
            return _format.parse(obj.get("$date").getAsString());
          } catch (ParseException e) {
            try {
View Full Code Here

      return enforceTypeNamingPolicy(jaje, nDepth + 1); // keep going until you find primitive/object
    }
    else if (je.isJsonObject()) {
      JsonObject jo = je.getAsJsonObject();
      // Nested variables:
      Iterator<Entry<String, JsonElement>> it = jo.entrySet().iterator();
      StringBuffer newName = null;
      Map<String, JsonElement> toFixList = null;
      while (it.hasNext()) {
        boolean bFix = false;
        Entry<String, JsonElement> el = it.next();
View Full Code Here

      DocumentPojo doc = BaseApiPojo.getDefaultBuilder().create().fromJson(json, DocumentPojo.class);
     
      // ...And add metadata back again...
      if (null != tmp) {
        JsonObject tmpMeta = tmp.getAsJsonObject();
        for (Entry<String, JsonElement> entry: tmpMeta.entrySet()) {
          if (entry.getValue().isJsonArray()) {
            doc.addToMetadata(entry.getKey(), MongoDbUtil.encodeArray(entry.getValue().getAsJsonArray()));
          }
          else {
            BasicDBList dbl = new BasicDBList();
View Full Code Here

  }

  @Override
  public Data deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) {
    final JsonObject obj = json.getAsJsonObject();
    final Set<Map.Entry<String, JsonElement>> entrySet = obj.entrySet();
    final DataBuilder builder = new DataBuilder();
    for (final Map.Entry<String, JsonElement> entry : entrySet) {
      final List<BrowserPattern> browserPatterns = deserializeType(context, entry, SerializableDataField.BROWSERPATTERNS,
          BrowserPattern.class);
      for (final BrowserPattern browserPattern : browserPatterns) {
View Full Code Here

        if (subscription instanceof JsonPrimitive) {
          return subscription.getAsString();
        }

        JsonObject subsObject = (JsonObject) subscription;
        Set<Entry<String, JsonElement>> entries = subsObject.entrySet();
        if (entries.size() != 1) {
          throw new ProtocolException(
              "Error format in response to subscription operation."
                  + "The response should have one property and it has "
                  + entries.size() + ". The response is: "
View Full Code Here

    }

    JsonObject jObject = (JsonObject) json;

    Props props = new Props();
    for (Map.Entry<String, JsonElement> e : jObject.entrySet()) {
      Object value = deserialize(e.getValue(), context);
      props.add(e.getKey(), value);
    }
    return props;
  }
View Full Code Here

    Query query = sessionFactory.getCurrentSession().getNamedQuery(queryName)
            .setResultTransformer(DistinctRootEntityResultTransformer.INSTANCE)
            .setCacheable(true);

    JsonObject parameterMap = parameters.getAsJsonObject();
    for (Map.Entry<String, JsonElement> element : parameterMap.entrySet()) {
      String key = element.getKey();
      JsonElement value = element.getValue();
      if (value.isJsonArray()) {
        JsonArray parametersArray = value.getAsJsonArray();
        List<String> parameterList = new ArrayList<String>();
View Full Code Here

    }
    if (element.isJsonPrimitive()) {
      addStringParam(paramName, element.getAsString());
    } else { // is JsonObject, so add individual members as values
      JsonObject json = element.getAsJsonObject();
      for (Map.Entry<String, JsonElement> member: json.entrySet()) {
        JsonElement valueElement = member.getValue();
        String valueAsJson = valueElement.isJsonPrimitive() ? valueElement.getAsString()
            : gson.toJson(valueElement);
        addStringParam(member.getKey(), valueAsJson);
      }
View Full Code Here

                                : theirFeatureType.type()));

                ImmutableList<PropertyDescriptor> descriptors = (ourFeatureType == null ? theirFeatureType
                        : ourFeatureType).sortedDescriptors();

                for (Entry<String, JsonElement> entry : merges.entrySet()) {
                    int descriptorIndex = getDescriptorIndex(entry.getKey(), descriptors);
                    if (descriptorIndex != -1 && entry.getValue().isJsonObject()) {
                        PropertyDescriptor descriptor = descriptors.get(descriptorIndex);
                        JsonObject attributeObject = entry.getValue().getAsJsonObject();
                        if (attributeObject.has("ours")
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.