-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Erroneous check in JSONObject merge Method #51
Comments
Thanks for the notice, I may have done that on purpose. I won't try to fix it, without a sample that will cause an invalid behavior. |
I wonder what purpose there could be for the check as it is. Since If this has not been a problem so far, then in practise the method is never called with null, the check is always true and the last two lines of the method are dead code. Just to be clear, I was taking about this method:
|
So let me read the code. JSONObject.java, I have 2 method: I think that the purpose of this code is to be able to merge:
in both case the result will be: even if only the second one is valid. By the way, the merge function can not merge json-smart was not build to be strict, the strict mode had been added to match JSON community requests. |
I had a look at this from the Java perspective, so what Java object would If I understand correctly the code should do the following:
To achieve this you need to check that the second parameter is an array or not. Thus, the type of The problem will occur if you want to merge P.S.: I will not be able to answer the next few day, but will at the end of the week. |
I noticed a problem in the method
protected static JSONArray merge(JSONArray o1, Object o2)
of the JSONObject class. It contains the following check:which does not make much sense, since o1 is already of type JSONArray. I believe o2 was meant to be checked here. The implementation would then be analogous to the method
protected static JSONObject merge(JSONObject o1, Object o2)
.Since I only spotted this by coincidence, I do not know the effects of this bug.
The text was updated successfully, but these errors were encountered: