I'm currently writing a jsonrpc-client in java. A request is represented by an JSONObject like this:
{'method': 'do.stuff', 'params': ['asdf', 3, {'foo': 'bar'}]}
Now I want to implement a low-level request cache and for this I need a way to create a hash from a JSONObject that will always return the same value. Using the toString() is not an option since JSONObjects are unordered: the following example would do exactly the same as my first example even though the string representation is different:
{'params': ['asdf', 3, {'foo': 'bar'}], 'method': 'do.stuff'}
Whats the best solution to this problem? The jsonobject may be nested to any arbitrary depth of course. I'm fairly new to Java and thankful for any suggestion.