I think the use of dictionary would be more appropriate here.
But better to do such things on the server, imo.