Created
March 26, 2017 08:23
-
-
Save alexanderjamesking/f73be43212ce23636189471afaad4c93 to your computer and use it in GitHub Desktop.
Transform.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ajk; | |
import clojure.lang.IFn; | |
import java.io.ByteArrayInputStream; | |
import java.io.IOException; | |
import static clojure.java.api.Clojure.read; | |
import static clojure.lang.RT.loadResourceScript; | |
import static clojure.lang.RT.var; | |
public final class Transform { | |
private final IFn xmlToJson; | |
public Transform() throws IOException { | |
// load libraries used by the transform script | |
final IFn require = var("clojure.core", "require"); | |
require.invoke(read("clojure.xml")); | |
require.invoke(read("clojure.zip")); | |
require.invoke(read("clojure.data.json")); | |
require.invoke(read("clojure.data.zip.xml")); | |
loadResourceScript("com/ajk/transform.clj"); | |
xmlToJson = var("transform", "xml-to-json"); | |
} | |
public String xmlToJson(final String xml) { | |
return (String) xmlToJson.invoke(new ByteArrayInputStream(xml.getBytes())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment