Skip to content

Commit

Permalink
Add tag s@script.to_json
Browse files Browse the repository at this point in the history
Other than an unspecified type key and forced uppercase, this is a
pretty solid JSON conversion.
  • Loading branch information
mcmonkey4eva committed Nov 3, 2014
1 parent f8bdc12 commit 24513dd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.utilities.YamlConfiguration;
import org.json.JSONObject;

public class dScript implements dObject {

Expand Down Expand Up @@ -450,6 +451,12 @@ else return new Element(TagManager.tag(attribute.getScriptEntry() == null ? null
return new Element(getObjectType()).getAttribute(attribute.fulfill(1));
}

if (attribute.startsWith("to_json")) {
JSONObject jsobj = new JSONObject(container.getConfigurationSection("").getMap());
jsobj.remove("TYPE");
return new Element(jsobj.toString()).getAttribute(attribute.fulfill(1));
}

// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this)) {
String returned = property.getAttribute(attribute);
Expand Down

0 comments on commit 24513dd

Please sign in to comment.