java.lang.Object
org.miaixz.bus.extra.json.JsonFactory
Factory for creating JSON provider instances. This factory automatically detects the JSON library introduced by the
user (e.g., Jackson, Gson, Fastjson) and creates a corresponding JSON parser.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonProvidercreate()Creates a new instance ofJsonProviderbased on the JSON engine JARs available on the classpath.static JsonProviderget()Retrieves the singleton instance ofJsonProvider.
-
Constructor Details
-
JsonFactory
public JsonFactory()
-
-
Method Details
-
get
Retrieves the singleton instance ofJsonProvider. The provider is created based on the first available JSON library found on the classpath via SPI.- Returns:
- The singleton
JsonProviderinstance.
-
create
Creates a new instance ofJsonProviderbased on the JSON engine JARs available on the classpath. It is recommended to use the singleton instance provided byget()for better performance, as this method creates a new engine instance on each call.- Returns:
- A new
JsonProviderinstance. - Throws:
org.miaixz.bus.core.lang.exception.InternalException- if no JSON library (e.g., Jackson, Gson, Fastjson) is found on the classpath.
-