com.github.bloodshura.ignitium.cfg.json.handling.JsonComposer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ignitium-cfg Show documentation
Show all versions of ignitium-cfg Show documentation
A collection of configuration and serialization readers and writers, like JSON, internationalization (I18n), and CSV.
package com.github.bloodshura.ignitium.cfg.json.handling;
import com.github.bloodshura.ignitium.cfg.json.JsonArray;
import com.github.bloodshura.ignitium.cfg.json.JsonObject;
import com.github.bloodshura.ignitium.charset.TextBuilder;
import com.github.bloodshura.ignitium.collection.list.XListIterator;
import com.github.bloodshura.ignitium.collection.tuple.Pair;
import com.github.bloodshura.ignitium.io.stream.TextWriter;
import com.github.bloodshura.ignitium.resource.OutputResource;
import com.github.bloodshura.ignitium.worker.StringWorker;
import javax.annotation.Nonnull;
import java.io.IOException;
public class JsonComposer {
public static void compose(@Nonnull JsonArray array, @Nonnull OutputResource resource, boolean pretty) throws IOException {
try (TextWriter writer = new TextWriter(resource)) {
arrayCompose(array, writer, new TextBuilder(), pretty);
}
}
public static void compose(@Nonnull JsonObject object, @Nonnull OutputResource resource, boolean pretty) throws IOException {
try (TextWriter writer = new TextWriter(resource)) {
objectCompose(object, writer, new TextBuilder(), pretty);
}
}
protected static void arrayCompose(@Nonnull JsonArray array, @Nonnull TextWriter writer, @Nonnull TextBuilder prefix, boolean pretty) throws IOException {
writer.write('[');
if (pretty) {
writer.newLine();
prefix.append('\t');
}
XListIterator
© 2015 - 2025 Weber Informatics LLC | Privacy Policy