I have a small question,
I mean I have a little problem…
I try to check if a a json nested value the same as a variable,
they are, but my debug say they are not, but they are exactly the same.
String license_key = "--license-key--";
try {
JSONObject json = JSONReader.readJsonFromUrl("https://api.chunkfactory.com?pid=1279&key=" + license_key);
JSONObject innerLicense = json.getJSONObject("license");
if (innerLicense.getString("license_key") == license_key) {
System.out.println("Yes");
} else {
System.out.println("No");
}
} catch (IOException e) {
e.printStackTrace();
}
>Solution :
for comparison of strings , we should use the equals method and not the == operator.
The == operator just compares the references and equals method checks if they have the same value.