congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
JsonArray.getValue
Code IndexAdd Tabnine to your IDE (free)

How to use
getValue
method
in
jodd.json.JsonArray

Best Java code snippets using jodd.json.JsonArray.getValue (Showing top 2 results out of 315)

origin: oblac/jodd

  @Override
  public boolean serialize(final JsonContext jsonContext, final JsonArray jsonArray) {
    final int length = jsonArray.size();

    if (length == 0 && jsonContext.isExcludeEmpty()) {
      return true;
    }

    jsonContext.writeOpenArray();

    int count = 0;

    for (int i = 0; i < length; i++) {
      if (count > 0) {
        jsonContext.writeComma();
      }

      if (jsonContext.serialize(jsonArray.getValue(i))) {
        count++;
      }
    }

    jsonContext.writeCloseArray();

    return true;
  }
}
origin: oblac/jodd

@Test
void testGetValue() {
  jsonArray.add(123);
  assertEquals(123, jsonArray.getValue(0));
  jsonArray.add(123L);
  assertEquals(123L, jsonArray.getValue(1));
  jsonArray.add(123f);
  assertEquals(123f, jsonArray.getValue(2));
  jsonArray.add(123d);
  assertEquals(123d, jsonArray.getValue(3));
  jsonArray.add(false);
  assertEquals(false, jsonArray.getValue(4));
  jsonArray.add(true);
  assertEquals(true, jsonArray.getValue(5));
  jsonArray.add("bar");
  assertEquals("bar", jsonArray.getValue(6));
  JsonObject obj = new JsonObject().put("blah", "wibble");
  jsonArray.add(obj);
  assertEquals(obj, jsonArray.getValue(7));
  JsonArray arr = new JsonArray().add("blah").add("wibble");
  jsonArray.add(arr);
  assertEquals(arr, jsonArray.getValue(8));
  byte[] bytes = randomByteArray(100);
  jsonArray.add(bytes);
  assertArrayEquals(bytes, Base64.getDecoder().decode((String) jsonArray.getValue(9)));
  jsonArray.addNull();
  assertNull(jsonArray.getValue(10));
  try {
    jsonArray.getValue(-1);
    fail("error");
jodd.jsonJsonArraygetValue

Javadoc

Returns the object value at position pos in the array.

Popular methods of JsonArray

  • <init>
    Creates an instance from a List. The List is not copied.
  • list
    Returns the underlying list.
  • size
    Returns the number of values in this JSON array.
  • add
    Adds a binary value to the JSON array. JSON has no notion of binary so the binary will be base64 enc
  • addAll
    Appends all of the elements in the specified array to the end of this JSON array.
  • addNull
    Adds a null value to the JSON array.
  • arrayEquals
  • clear
    Removes all entries from the JSON array.
  • contains
    Returns true if given value exist.
  • equals
  • getBinary
    Returns the byte[] at position pos in the array. JSON itself has no notion of a binary, so this meth
  • getBoolean
    Returns the boolean at position pos in the array.
  • getBinary,
  • getBoolean,
  • getDouble,
  • getFloat,
  • getInteger,
  • getJsonArray,
  • getJsonObject,
  • getLong,
  • getString

Popular in Java

  • Parsing JSON documents to java classes using gson
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • findViewById (Activity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now