Package javax.json

Examples of javax.json.JsonValue


                String.format(
                    "'%s' is absent in JSON: %s", name, json
                )
            );
        }
        final JsonValue value = json.get(name);
        if (value == null) {
            throw new IllegalStateException(
                String.format(
                    "'%s' is NULL in %s", name, json
                )
            );
        }
        if (value.getClass().isAssignableFrom(type)) {
            throw new IllegalStateException(
                String.format(
                    "'%s' is not of type %s", name, type
                )
            );
View Full Code Here


     * @throws IOException If there is any I/O problem
     */
    public boolean hasNotNull(
        @NotNull(message = "name can't be NULL") final String name
    ) throws IOException {
        final JsonValue value = this.object.json().get(name);
        return value != null
            && !ValueType.NULL.equals(value.getValueType());
    }
View Full Code Here

     * @return Value as a string
     * @throws IOException If some problem inside
     */
    private String value(final Release release, final String name)
        throws IOException {
        final JsonValue jsonValue = release.json().get(name);
        String result = null;
        if (jsonValue instanceof JsonString) {
            result = ((JsonString) jsonValue).getString();
        }
        return result;
View Full Code Here

            JsonArray childArray = (JsonArray)jsonValue;
            int size = childArray.size();
              
            List list = new ArrayList(size);           
            for(int x=0; x<size; x++) {
                JsonValue nextArrayValue = childArray.get(x);
                parseValue(nextArrayValue);
            }
        }
  }
View Full Code Here

                        }
                    }
                }

                for (int i = 0; i < arraySize; i++) {
                    JsonValue nextArrayValue = jsonArray.get(i);
                    if (nextArrayValue.getValueType() == ValueType.NULL) {
                        ((UnmarshalRecord) contentHandler).setNil(true);
                    }

                    if (!isTextValue) {
                        if (null != itemXPathFragment) {
View Full Code Here

                    ArrayList<Attribute> attributesList = new ArrayList<Attribute>(jsonObject.values().size());

                    Iterator<Entry<String, JsonValue>> iter = jsonObject.entrySet().iterator();
                    while (iter.hasNext()) {
                        Entry<String, JsonValue> nextEntry = iter.next();
                        JsonValue nextValue = nextEntry.getValue();
                        String attributeLocalName = nextEntry.getKey();                      

                        if (attributePrefix != null) {
                            if (attributeLocalName.startsWith(attributePrefix)) {
                                attributeLocalName = attributeLocalName.substring(attributePrefix.length());
                            } else {
                                break;
                            }
                        }

                        String uri = Constants.EMPTY_STRING;

                        if (namespaceAware && namespaces != null) {
                            if (attributeLocalName.length() > 2) {
                                String prefix = Constants.EMPTY_STRING;
                                int nsIndex = attributeLocalName.indexOf(namespaceSeparator, 1);
                                if (nsIndex > -1) {
                                    prefix = attributeLocalName.substring(0, nsIndex);
                                }
                                uri = namespaces.resolveNamespacePrefix(prefix);
                                if (uri == null) {
                                    uri = namespaces.getDefaultNamespaceURI();
                                } else {
                                    attributeLocalName = attributeLocalName.substring(nsIndex + 1);
                                }
                            } else {
                                uri = namespaces.getDefaultNamespaceURI();
                            }
                        }

                        if (nextValue.getValueType() == ValueType.ARRAY) {
                            JsonArray jsonArray = (JsonArray) nextValue;
                            if (jsonArray.size() == 0) {
                                attributesList.add(new Attribute(uri, attributeLocalName, attributeLocalName, ""));
                            }
                            for (int y = 0; y < jsonArray.size(); y++) {
                                JsonValue nextChildValue = jsonArray.get(y);
                                addSimpleAttribute(attributesList, uri, attributeLocalName, nextChildValue);
                            }
                        } else {
                            addSimpleAttribute(attributesList, uri, attributeLocalName, nextValue);
                        }
View Full Code Here

      return;
    }
    JsonObject alternate = (JsonObject) theAlternateVal;
    for (Entry<String, JsonValue> nextEntry : alternate.entrySet()) {
      String nextKey = nextEntry.getKey();
      JsonValue nextVal = nextEntry.getValue();
      if ("extension".equals(nextKey)) {
        boolean isModifier = false;
        JsonArray array = (JsonArray) nextEntry.getValue();
        parseExtension(theState, array, isModifier);
      } else if ("modifierExtension".equals(nextKey)) {
        boolean isModifier = true;
        JsonArray array = (JsonArray) nextEntry.getValue();
        parseExtension(theState, array, isModifier);
      } else if ("id".equals(nextKey)) {
        switch (nextVal.getValueType()) {
        case STRING:
          theState.attributeValue("id", ((JsonString) nextVal).getString());
          break;
        case NULL:
          break;
View Full Code Here

  @Override
  public <T extends IResource> Bundle parseBundle(Class<T> theResourceType, Reader theReader) {
    JsonReader reader = Json.createReader(theReader);
    JsonObject object = reader.readObject();

    JsonValue resourceTypeObj = object.get("resourceType");
    assertObjectOfType(resourceTypeObj, JsonValue.ValueType.STRING, "resourceType");
    String resourceType = ((JsonString) resourceTypeObj).getString();
    if (!"Bundle".equals(resourceType)) {
      throw new DataFormatException("Trying to parse bundle but found resourceType other than 'Bundle'. Found: '" + resourceType + "'");
    }
View Full Code Here

        theState.string(theObject.getString(nextName, null));
        theState.endingElement();
        continue;
      }

      JsonValue nextVal = theObject.get(nextName);
      parseChildren(theState, nextName, nextVal, null);

    }
  }
View Full Code Here

        continue;
      } else if (nextName.charAt(0) == '_') {
        continue;
      }

      JsonValue nextVal = theObject.get(nextName);
      JsonValue alternateVal = theObject.get('_' + nextName);

      parseChildren(theState, nextName, nextVal, alternateVal);

    }
View Full Code Here

TOP

Related Classes of javax.json.JsonValue

Copyright © 2018 www.massapicom. 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.