Class Viv.KeyValue<T>

java.lang.Object
com.benesult.vivjson.Viv.KeyValue<T>
Enclosing class:
Viv

public static class Viv.KeyValue<T> extends Object
Key-Value pair data class. Mostly, this will be elements of the array. Then it is used to represent HashMap.

For example,


   // {"a": 10, "b": 20}
   String code = "{\"a\": 10, \"b\": 20}";
   try {
     Object object = Viv.runEx(code);
     Viv.KeyValue<Integer>[] pairs = Viv.getKeyValueIntegersEx(object);
     for (Viv.KeyValue<Integer> pair : pairs) {
       System.out.println(pair.key + ": " + pair.value);
     }
   } catch (VivException e) {
     System.err.println(e.getMessage());
   }
 
  • Field Details

    • key

      public final String key
      Key of key-value pair. It is so called Name.
    • value

      public final T value
      Value of key-value pair. Its value type is generic. It is assumed that Boolean, Integer, Long, Float, Double, or String.
      In addition, @Nullable may be added.
  • Constructor Details

    • KeyValue

      public KeyValue(String key, T value)