Package javax.json

Examples of javax.json.JsonValue


  @Override
  public <T extends IResource> T parseResource(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();

    RuntimeResourceDefinition def;
    if (theResourceType != 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

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

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

    }
  }
View Full Code Here

    switch (theJsonVal.getValueType()) {
    case ARRAY: {
      JsonArray nextArray = (JsonArray) theJsonVal;
      JsonArray nextAlternateArray = (JsonArray) theAlternateVal;
      for (int i = 0; i < nextArray.size(); i++) {
        JsonValue nextObject = nextArray.get(i);
        JsonValue nextAlternate = null;
        if (nextAlternateArray != null) {
          nextAlternate = nextAlternateArray.get(i);
        }
        parseChildren(theState, theName, nextObject, nextAlternate);
      }
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

          parseExtension(theState, jsonVal, false);
        } else if ("modifierExtension".equals(next)) {
          JsonArray jsonVal = (JsonArray) nextExtObj.get(next);
          parseExtension(theState, jsonVal, true);
        } else {
          JsonValue jsonVal = nextExtObj.get(next);
          parseChildren(theState, next, jsonVal, null);
        }
      }
      theState.endingElement();
    }
View Full Code Here

  @Override
  public Bundle parseBundle(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

            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

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.