Package javax.json

Examples of javax.json.JsonArray


                                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


    }

    @Test
    public void convertEmptyListToJson() {
        mockQuery(Registration.findAll, Collections.EMPTY_LIST);
        final JsonArray result = this.cut.allAsJson();
        assertNotNull(result);
        assertTrue(result.isEmpty());
    }
View Full Code Here

        List<Registration> registrations = new ArrayList<>();
        Registration expected = mock(Registration.class);
        when(expected.getId()).thenReturn(42l);
        registrations.add(expected);
        mockQuery(Registration.findAll, registrations);
        final JsonArray result = this.cut.allAsJson();
        assertNotNull(result);
        assertThat(result.size(), is(1));
        JsonObject actual = result.getJsonObject(0);
        JsonNumber actualId = actual.getJsonNumber(Registrations.CONFIRMATION_ID);
        assertThat(expected.getId(), is(actualId.longValue()));

    }
View Full Code Here

    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());
View Full Code Here

  private void parseBundleChildren(JsonObject theObject, ParserState<?> theState) {
    for (String nextName : theObject.keySet()) {
      if ("resourceType".equals(nextName)) {
        continue;
      } else if ("link".equals(nextName)) {
        JsonArray entries = theObject.getJsonArray(nextName);
        for (JsonValue jsonValue : entries) {
          theState.enteringNewElement(null, "link");
          JsonObject linkObj = (JsonObject) jsonValue;
          String rel = linkObj.getString("rel", null);
          String href = linkObj.getString("href", null);
          theState.attributeValue("rel", rel);
          theState.attributeValue("href", href);
          theState.endingElement();
        }
        continue;
      } else if ("entry".equals(nextName)) {
        JsonArray entries = theObject.getJsonArray(nextName);
        for (JsonValue jsonValue : entries) {
          theState.enteringNewElement(null, "entry");
          parseBundleChildren((JsonObject) jsonValue, theState);
          theState.endingElement();
        }
View Full Code Here

        continue;
      } else if ("id".equals(nextName)) {
        elementId = theObject.getString(nextName);
        continue;
      } else if ("extension".equals(nextName)) {
        JsonArray array = theObject.getJsonArray(nextName);
        parseExtension(theState, array, false);
        continue;
      } else if ("modifierExtension".equals(nextName)) {
        JsonArray array = theObject.getJsonArray(nextName);
        parseExtension(theState, array, true);
        continue;
      } else if (nextName.charAt(0) == '_') {
        continue;
      }
View Full Code Here

  }

  private void parseChildren(ParserState<?> theState, String theName, JsonValue theJsonVal, JsonValue theAlternateVal) {
    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);
      }
      break;
    }
View Full Code Here

      for (Iterator<String> iter = nextExtObj.keySet().iterator(); iter.hasNext();) {
        String next = iter.next();
        if ("url".equals(next)) {
          continue;
        } else if ("extension".equals(next)) {
          JsonArray jsonVal = (JsonArray) nextExtObj.get(next);
          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);
        }
View Full Code Here

          .add("sensors", buildSensorArray(room))
          .add("actuators", buildActuatorArray(room))
          .add("controllers", buildControllerArray(room));
      roomBuilder.add(roomObjectBuilder.build());
    }
    JsonArray roomArray = roomBuilder.build();
    return roomArray;
  }
View Full Code Here

  private static JsonArray buildColorArray(final Simulation simulation) {
    JsonArrayBuilder colorArrayBuilder = Json.createArrayBuilder();
    int[] lightColor = simulation.getContext().getLightColor();
    colorArrayBuilder.add(lightColor[0]).add(lightColor[1])
        .add(lightColor[2]);
    JsonArray colorArray = colorArrayBuilder.build();
    return colorArray;
  }
View Full Code Here

TOP

Related Classes of javax.json.JsonArray

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.