Class JSONParser
java.lang.Object
studio.magemonkey.codex.mccore.config.parse.JSONParser
Custom parser for JSON that doesn't trim whitespace or newlines
as it is meant for storing data, not for super readable files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddump(DataSection data, StringBuilder builder) Dumps config data to a string in JSON formatstatic DataSectionReads and then parses data from the file.static DataSectionReads and then parses data from the file at the given path.static DataSectionparseResource(org.bukkit.plugin.Plugin plugin, String path) Reads and then parses data from an embedded plugin resource.static DataSectionParses the text read in from a file.static voidsave(DataSection data, BufferedWriter write) Dumps the data contents into the streamstatic voidsave(DataSection data, File file) Dumps the data contents to a file to the given filestatic voidsave(DataSection data, String path) Saves config data to a file
-
Constructor Details
-
JSONParser
public JSONParser()
-
-
Method Details
-
parseResource
Reads and then parses data from an embedded plugin resource. If the resource does not exist or doesn't contain any data, this will return an empty DataSection object.- Parameters:
plugin- plugin containing the embedded resourcepath- path to the resource (not including the beginning slash)- Returns:
- loaded data
-
parseFile
Reads and then parses data from the file at the given path. If the file does not exist or doesn't contain any data, this will return an empty DataSection object.- Parameters:
path- path to the file load from- Returns:
- loaded data
-
parseFile
Reads and then parses data from the file. If the file does not exist or doesn't contain any data, this will return an empty DataSection object.- Parameters:
file- the file load from- Returns:
- loaded data
-
parseText
Parses the text read in from a file. If a null string is passed in, this will return an empty data section.- Parameters:
text- text to parse- Returns:
- parsed data
-
save
Saves config data to a file- Parameters:
path- path to the file
-
save
Dumps the data contents to a file to the given file- Parameters:
file- file to dump to
-
save
Dumps the data contents into the stream- Parameters:
write- stream to dump to- Throws:
IOException
-
dump
Dumps config data to a string in JSON format- Parameters:
data- data to dumpbuilder- string builder to use
-