Fix for bug 439773 - Construct JsonArray from any List.

I saw this is already fixed in the master branch, but not in the 2.x branch.
These changes make 2.x branch in sync with master branch regarding this issue.
Added test cases.