Schnittstelle JSONHelper

Alle bekannten Implementierungsklassen:
ClassBase, EntityBase, GHActionsCache, GHAdvisory, GHAlert, GHArtifact, GHBase, GHBranch, GHEvent, GHFile, GHFileBuilder, GHGitignoreTemplate, GHHook, GHIssue, GHIssueBuilder, GHLabel, GHLicense, GHMilestone, GHOrganisation, GHPackage, GHPages, GHPermission, GHPlan, GHProject, GHProjectBuilder, GHPublicKey, GHPublicKeyBuilder, GHPullRequest, GHRepository, GHRepositoryCache, GHSecret, GHStep, GHTeam, GHTeamBuilder, GHUser, GHVariable, GHVulnerability, GHWorkflowJob, GHWorkflowRun, Github, HttpsCertificate, SelfUser

public interface JSONHelper
This interface provides helper methods for working with JSON objects.
  • Verschachtelte Klassen - Übersicht

    Verschachtelte Klassen
    Modifizierer und Typ
    Schnittstelle
    Beschreibung
    static interface 
    This functional interface defines a method to create an object of type T from a JSON object.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    default <T> List<T>
    getArrayOrNull(org.json.JSONObject jsonObject, String key, JSONHelper.JSONToObject<T> factory)
    Returns a list of objects of type T, created from a JSON array in the JSON object using the provided factory method.
    default boolean
    getBooleanOrNull(org.json.JSONObject jsonObject, String key)
    Returns the boolean value of the specified key in the JSON object, or false if the key is not present.
    default Integer
    getIntOrNull(org.json.JSONObject jsonObject, String key)
    Returns the integer value of the specified key in the JSON object, or 0 if the key is not present.
    default List<String>
    getJSONArrayToStringList(org.json.JSONObject jsonObject, String key)
     
    default org.json.JSONObject
    getJSONObjectOrNull(org.json.JSONObject jsonObject, String key)
    Returns the JSON object value of the specified key in the JSON object, or null if the key is not present.
    getLocalDateOrNull(org.json.JSONObject jsonObject, String key)
    Returns the OffsetDateTime value of the specified key in the JSON object, or null if the key is not present.
    default Long
    getLongOrNull(org.json.JSONObject jsonObject, String key)
    Returns the long value of the specified key in the JSON object, or 0 if the key is not present.
    default String
    getStringOrNull(org.json.JSONObject jsonObject, String key)
    Returns the string value of the specified key in the JSON object, or null if the key is not present.
  • Methodendetails

    • getStringOrNull

      default String getStringOrNull(org.json.JSONObject jsonObject, String key)
      Returns the string value of the specified key in the JSON object, or null if the key is not present.
      Parameter:
      jsonObject - the JSON object
      key - the key
      Gibt zurück:
      the string value or null
    • getIntOrNull

      default Integer getIntOrNull(org.json.JSONObject jsonObject, String key)
      Returns the integer value of the specified key in the JSON object, or 0 if the key is not present.
      Parameter:
      jsonObject - the JSON object
      key - the key
      Gibt zurück:
      the integer value or 0
    • getLongOrNull

      default Long getLongOrNull(org.json.JSONObject jsonObject, String key)
      Returns the long value of the specified key in the JSON object, or 0 if the key is not present.
      Parameter:
      jsonObject - the JSON object
      key - the key
      Gibt zurück:
      the long value or 0
    • getBooleanOrNull

      default boolean getBooleanOrNull(org.json.JSONObject jsonObject, String key)
      Returns the boolean value of the specified key in the JSON object, or false if the key is not present.
      Parameter:
      jsonObject - the JSON object
      key - the key
      Gibt zurück:
      the boolean value or false
    • getJSONObjectOrNull

      default org.json.JSONObject getJSONObjectOrNull(org.json.JSONObject jsonObject, String key)
      Returns the JSON object value of the specified key in the JSON object, or null if the key is not present.
      Parameter:
      jsonObject - the JSON object
      key - the key
      Gibt zurück:
      the JSON object value or null
    • getLocalDateOrNull

      default OffsetDateTime getLocalDateOrNull(org.json.JSONObject jsonObject, String key)
      Returns the OffsetDateTime value of the specified key in the JSON object, or null if the key is not present.
      Parameter:
      jsonObject - the JSON object
      key - the key
      Gibt zurück:
      the OffsetDateTime value or null
    • getArrayOrNull

      default <T> List<T> getArrayOrNull(org.json.JSONObject jsonObject, String key, JSONHelper.JSONToObject<T> factory)
      Returns a list of objects of type T, created from a JSON array in the JSON object using the provided factory method. If the key is not present, returns null.
      Parameter:
      jsonObject - the JSON object
      key - the key
      factory - the factory method to create objects of type T from a JSON object
      Gibt zurück:
      the list of objects or null
    • getJSONArrayToStringList

      default List<String> getJSONArrayToStringList(org.json.JSONObject jsonObject, String key)