"<list of lists><array>1</array><array>2</array><array>3</array></list of lists><list of lists><array>4</array><array>5</array><array>6</array></list of lists>",
XML.toString(jsonobject));
} catch (JSONExceptione)
{
fail(e.toString());
}
}
/**
* Tests the toJSONObject method using xml recipe.
*/
publicvoidtestToJSONObject_XmlRecipe()
{
try
{
string = "<recipe name=\"bread\" prep_time=\"5 mins\" cook_time=\"3 hours\"> <title>Basic bread</title> <ingredient amount=\"8\" unit=\"dL\">Flour</ingredient> <ingredient amount=\"10\" unit=\"grams\">Yeast</ingredient> <ingredient amount=\"4\" unit=\"dL\" state=\"warm\">Water</ingredient> <ingredient amount=\"1\" unit=\"teaspoon\">Salt</ingredient> <instructions> <step>Mix all ingredients together.</step> <step>Knead thoroughly.</step> <step>Cover with a cloth, and leave for one hour in warm room.</step> <step>Knead again.</step> <step>Place in a bread baking tin.</step> <step>Cover with a cloth, and leave for one hour in warm room.</step> <step>Bake in the oven at 180(degrees)C for 30 minutes.</step> </instructions> </recipe> ";
jsonobject = XML.toJSONObject(string);
assertEquals(
"{\"recipe\": {\n\"title\": \"Basic bread\",\n\"cook_time\": \"3 hours\",\n\"instructions\": {\"step\": [\n\"Mix all ingredients together.\",\n\"Knead thoroughly.\",\n\"Cover with a cloth, and leave for one hour in warm room.\",\n\"Knead again.\",\n\"Place in a bread baking tin.\",\n\"Cover with a cloth, and leave for one hour in warm room.\",\n\"Bake in the oven at 180(degrees)C for 30 minutes.\"\n ]},\n\"name\": \"bread\",\n\"ingredient\": [\n {\n\"content\": \"Flour\",\n\"amount\": 8,\n\"unit\": \"dL\"\n },\n {\n\"content\": \"Yeast\",\n\"amount\": 10,\n\"unit\": \"grams\"\n },\n {\n\"content\": \"Water\",\n\"amount\": 4,\n\"unit\": \"dL\",\n\"state\": \"warm\"\n },\n {\n\"content\": \"Salt\",\n\"amount\": 1,\n\"unit\": \"teaspoon\"\n }\n ],\n\"prep_time\": \"5 mins\"\n}}",