Package de.coho04.githubapi.interfaces
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 KlassenModifizierer und TypSchnittstelleBeschreibungstatic interfaceThis functional interface defines a method to create an object of type T from a JSON object. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungdefault <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 booleangetBooleanOrNull(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 IntegergetIntOrNull(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.getJSONArrayToStringList(org.json.JSONObject jsonObject, String key) default org.json.JSONObjectgetJSONObjectOrNull(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.default OffsetDateTimegetLocalDateOrNull(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 LonggetLongOrNull(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 StringgetStringOrNull(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
Returns the string value of the specified key in the JSON object, or null if the key is not present.- Parameter:
jsonObject- the JSON objectkey- the key- Gibt zurück:
- the string value or null
-
getIntOrNull
Returns the integer value of the specified key in the JSON object, or 0 if the key is not present.- Parameter:
jsonObject- the JSON objectkey- the key- Gibt zurück:
- the integer value or 0
-
getLongOrNull
Returns the long value of the specified key in the JSON object, or 0 if the key is not present.- Parameter:
jsonObject- the JSON objectkey- the key- Gibt zurück:
- the long value or 0
-
getBooleanOrNull
Returns the boolean value of the specified key in the JSON object, or false if the key is not present.- Parameter:
jsonObject- the JSON objectkey- the key- Gibt zurück:
- the boolean value or false
-
getJSONObjectOrNull
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 objectkey- the key- Gibt zurück:
- the JSON object value or null
-
getLocalDateOrNull
Returns the OffsetDateTime value of the specified key in the JSON object, or null if the key is not present.- Parameter:
jsonObject- the JSON objectkey- 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 objectkey- the keyfactory- the factory method to create objects of type T from a JSON object- Gibt zurück:
- the list of objects or null
-
getJSONArrayToStringList
-