json文件上传怎么校验
收起
云计算小粉
2018-05-10 19:59:58
1877
0
1
条回答
写回答
取消
提交回答
-
public static void main ( String[] args )
{
System.out.println ("随便输入一个JSON格式:(直接回车结束)");
Scanner scanner = new Scanner (System.in);
ScriptEngineManager sem = new ScriptEngineManager ();
ScriptEngine se = sem.getEngineByName ("js");
while (scanner.hasNextLine ())
{
String line = scanner.nextLine ().trim ();
if ("".equals (line))
{
break;
}
try
{
System.out.println (se.eval (line));
}
catch (ScriptException e)
{
System.out.println ("不合法的JSON,重新输入:");
continue;
}
}
scanner.close ();
}
2019-07-17 22:10:38