在 Java 中,我有一个 json 字符串,我想从中删除多余的空格。我不想删除键和值中字符的空格。
实际的 JSON 字符串
{ "Error" : "Invalid HTTP Method" , "ErrorCode" : "405" , "ErrorDesc" : "Method Not Allowed" }
Run Code Online (Sandbox Code Playgroud)
必需的 JSON
{"Error":"Invalid HTTP Method","ErrorCode":"405","ErrorDesc":"Method Not Allowed"}
Run Code Online (Sandbox Code Playgroud) 我试图通过 java 字符串创建表,但它显示错误,因为表不存在,但当我直接在工作台上运行相同的查询时,它运行良好。下面是我的代码
String url = "jdbc:mysql://localhost:3306/" ;
String dbname = "tweetmap";
String username = "root";
String password = "root";
try
{
// SQL Driver needed for connecting to Database
Class.forName("com.mysql.jdbc.Driver");
c = DriverManager.getConnection(url+dbname,username,password);
c.setAutoCommit(true);
stmt = c.createStatement();
//Creating the Database if not Already Present
String sql = "CREATE TABLE if not exists senti "
+ "( latitude double NULL, "
+ "longitude double NULL, "
+ "Sentiment TEXT NULL) ";
stmt.executeUpdate(sql);
if(sentiment != null){
stmt1 = c.createStatement(); …Run Code Online (Sandbox Code Playgroud)