Why do you need to convert a list of strings to an associative array? AngularJs can handle iteration over an array.
Here's a plnkr that demonstrates: http://plnkr.co/edit/TcXxSBkt7NBkqNJhkSE1
essentially, the server returns an object, and the SomeListItems property is an array.
use ng-repeat to iterate over them
<ul> <li ng-repeat="item in data.SomeListItems">{{item}}</li> </ul>
I see a couple of solutions to this problem, either by massaging the data structure on the client or on the server.
Here is plnkr , which shows the conversion of an array of strings received from the server into an associative array, so it can be edited on the client, and then re-converted back to one dimensional array for publication on the server.
Conversely, you can do this on the server. If you declare SomeListItems as a dynamic list, then you can assign everything you want, including anonymous objects that the ServiceStack serializer should handle (I have not tested this, but I think it will work).
[Route("/path/{Id}", "GET, OPTIONS")] public class MyModel { public int Id { get; set; } public List<dynamic> SomeListItems { get; set; } }
alternatively, you can specify a custom class that is less verbose than KeyValuePair<string, string>
public class JsonPayload {
and then redefine the model
[Route("/path/{Id}", "GET, OPTIONS")] public class MyModel { public int Id { get; set; } public List<JsonPayload> SomeListItems { get; set; } }
this is a little more verbose than using dynamics, but JSON serialization should definitely handle this.