Class JsonFunctions

java.lang.Object
org.apache.juneau.commons.svl.functions.JsonFunctions

public final class JsonFunctions extends Object
JSON-navigation functions for the #{...} script catalog.

All functions accept JSON strings as input and parse on each call via MiniJson. This is intentionally a per-resolve cost — for repeated lookups against the same JSON document the caller can pre-compile the surrounding template (VarResolver.compile(String)) so the tokenization is amortized; the JSON parse itself is not yet cached and is a known follow-on optimization opportunity.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    #{get(json, key)} — extracts json[key] (object) or json[index] (array, when key parses as int).
    static class 
    #{jsonPath(json, path)} / #{jsonPath(json, path, default)} — extracts a value via a slash-rooted path (e.g.
    static class 
    #{keys(json)} — returns a JSON-array-shortcut string of an object's keys.
    static class 
    #{size(json)} — returns the count: object key count, array length, string length, or 0 for null/primitives.
    static class 
    #{values(json)} — returns a JSON-array-shortcut string of an object's values (or array elements).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Class<? extends VarFunction>[]
    All function classes in this category.
  • Method Summary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ALL

      public static final Class<? extends VarFunction>[] ALL
      All function classes in this category.