mvel icon indicating copy to clipboard operation
mvel copied to clipboard

Maintain order when using inline maps and lists

Open newoga opened this issue 10 years ago • 0 comments

First of all, awesome tool. I just recently starting messing around with MVEL.

I sent an email to the user mailing list this morning regarding the possibility of switching the parser's Map implementation from HashMap to LinkedHashMap so that the order of keys are maintained based on insertion.

My primary use case this functionality was so that I could have a nice syntax to build maps for a JSON serializer. For REST APIs, I prefer when the JSON keys are ordered in a predictable way and are consistent with API documentation.

This pull request has what I think are the necessary changes, and it includes a test that confirms the order works (test would break if HashMap implementation was kept).

newoga avatar Jul 03 '14 21:07 newoga