JsonUtil
fromFile
â
This method is used to parse the given JSON file to Java object.
import static io.github.boykaframework.utils.JsonParser.fromFile;
. . .
Users users = fromFile ("/path/to/file.json", Users.class);
toFile
â
This method is used to write the given JSON object to the given file.
import static io.github.boykaframework.utils.JsonParser.toFile;
. . .
toFile (users, "/path/to/file.json");
toString(object)
â
This method is used to convert the given object to JSON string.
import static io.github.boykaframework.utils.JsonParser.toString;
. . .
System.out.println (toString (users));
toString(string)
â
This method is used to pretty-print the given JSON string.
import static io.github.boykaframework.utils.JsonParser.toString;
. . .
String jsonString = "{\"name\":\"Wasiq\",\"age\":25}";
System.out.println (toString (jsonString));