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
Exctract on JSONObject #484
Comments
there is one problem for that : assertj-core does not use any dependencies so it can't know JSONObjects. You can try to use an extractor (specially handy with java 8 lambdas) that implements the logic of extracting the data you need to check. |
Thanks, @joel-costigliola That's right, my intention was mostly to confirm that I can't achieve this goal by other means other than custom assertions and custom extractors. So just to confirm that I'm on the right path - I should use the ByMapKeyExtractor.java class as template, but use JSONObject instead of Map<K, V>, right? Here is the reference to this class: 2dcc837 I realize that assertj-core is not a proper place for that. But do you have any recommended pattern to build out and organize a library like the one for #75 to keep all the extractors etc in place for json-simple object? I anticipate that I'll have to create quite a number of them eventually. |
You are in the right track with Regarding the JSON assertion module, follow what has been done for assertj-guava. cheers |
I'm closing this issue as it can't be solved in assertj-core. |
Hi.
As per #258 I should be able to extract values by keys in Map objects.
I'm wondering now if I can do something with the same level of convenience with JSONObjects as well, since they behave to some extent in a very similar way.
Assuming I have following JSON Array of JSON Objects:
I'd like to iterate (which AssertJ does) and verify extracting values by key name:
Currently it results in following exception:
Is there any way to make it work given the fact that getting the value is like that:
Note: I'm using com.googlecode.json-simple 1.1.1 now to work with JSON.
In general I would also reconsider decision on #75 What's currently recommended way/library to work with AssertJ and JSON objects?
The text was updated successfully, but these errors were encountered: