mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-11 11:55:03 -05:00
Add Object.toJsonString() convenience extension method
This commit is contained in:
parent
e2d867dc4d
commit
1a7e7b06c3
@ -34,6 +34,7 @@ import java.util.logging.Level;
|
||||
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
|
||||
import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
|
||||
|
||||
import groovy.json.JsonBuilder;
|
||||
import groovy.lang.Closure;
|
||||
import groovy.lang.Range;
|
||||
import net.filebot.MediaTypes;
|
||||
@ -449,6 +450,10 @@ public class ScriptShellMethods {
|
||||
return MediaDetection.isMovie(self, true);
|
||||
}
|
||||
|
||||
public static Object toJsonString(Object object) {
|
||||
return new JsonBuilder(object).toPrettyString();
|
||||
}
|
||||
|
||||
public static String format(Date self, String format) {
|
||||
// XXX: org.apache.groovy.datetime.extensions.DateTimeExtensions is not registered for some reason in production (maybe a bug specific to Groovy 2.5.0)
|
||||
return DateTimeFormatter.ofPattern(format, Locale.US).format(LocalDateTime.ofInstant(self.toInstant(), ZoneId.systemDefault()));
|
||||
|
Loading…
Reference in New Issue
Block a user