Package com.thecoderscorner.menu.persist
Class JsonMenuItemSerializer
java.lang.Object
com.thecoderscorner.menu.persist.JsonMenuItemSerializer
Creates a menu serializer instance that can convert menu structures to and from JSON format. In the simplest case
just create a new instance of the class and you can use it to convert between formats.
var jsonSerializer = new JsonMenuItemSerializer();
var tree = jsonSerializer.newMenuTreeWithItems(textCopiedFromTcMenuDesigner);
var json = jsonSerializer.itemsToCopyText(MenuTree.ROOT, tree);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopyTextToItems(String items) com.google.gson.GsongetGson()static intgetJsonIntOrThrow(com.google.gson.JsonObject object, String child) static com.google.gson.JsonObjectgetJsonObjOrThrow(com.google.gson.JsonObject object, String child) static StringgetJsonStrOrThrow(com.google.gson.JsonObject object, String child) itemsToCopyText(MenuItem startingPoint, MenuTree tree) newMenuTreeWithItems(String tcMenuCopy) populateListInOrder(SubMenuItem node, MenuTree menuTree)
-
Constructor Details
-
JsonMenuItemSerializer
public JsonMenuItemSerializer() -
JsonMenuItemSerializer
-
-
Method Details
-
getGson
public com.google.gson.Gson getGson() -
copyTextToItems
-
newMenuTreeWithItems
-
getJsonObjOrThrow
public static com.google.gson.JsonObject getJsonObjOrThrow(com.google.gson.JsonObject object, String child) throws IOException - Throws:
IOException
-
getJsonStrOrThrow
public static String getJsonStrOrThrow(com.google.gson.JsonObject object, String child) throws IOException - Throws:
IOException
-
getJsonIntOrThrow
public static int getJsonIntOrThrow(com.google.gson.JsonObject object, String child) throws IOException - Throws:
IOException
-