询问mldy/pgettingdeprecatedmessageforjsonparserforspringbootapp,
jonobjectjsonobject=newjsonparser (.parse (result ).getAsJsonObject );
What is the alternative?
Based on the javadoc for Gson 2.8.6
No need to instantiate this class,use the static methods instead。
andfollowingarethealternativestobeused。
//jsonString is of type java.lang .无形糖精/pjsonobjectjsonobject=JSON parser.parse string (JSON string ).getasjsonon
//readerisoftypejava.io.yjdjj/pjsonobjectjsonobject=JSON parser.parsereader (reader ).getAsJsonObject;
//jsonreaderisoftypecom.Google.gson.stream.jsonyjdjj/pjsonobjectjsonobject=JSON parser.parsereader (
Example
importstaticorg.JUnit.assert.assert true;
import com.Google.gson.JSON object;
import com.Google.gson.JSON parser;
公共类测试{
publicstaticvoidmain (字符串的拼命口红args ) )。
stringjsonstring=' {' name' :'高贵的电脑} ';
jsonobjectjsonobjectalt=JSON parser.parse string (JSON string ).getAsJsonObject );
//showsdeprecatedwarningfornewjsonparser () and parse (JSON string ) )。
jsonobjectjsonobject=newjsonparser (.parse ) JSONstring ).getAsJsonObject;
assert true (jsonobjectalt.equals ) JSONobject );
}
资料来源: https://stack overflow.com/questions/60771386/JSON parser-is-deprecated