My ApiController method is returning JSON in this format:
"[{\"Category\":{\"CategoryType\":{\"Categories\":[{\"Client\":{\"Categories\":[{\"CategoryType\":{\"Categories\":[{\"Controls\":[],\"Risks\":[{\"Controls\":[],\"PCRMaps\":[],\"Id\":3,\"Title\":\"Risk with ID\",\"Description\":\"Test\",\"CategoryId\":80, etc etc
I have AngularJS code to render a drop-down list from this JSON object, as follows:
<select ng-model="newRisk.ClientId" id="ddlClient" name="ddlClient">
<option></option>
<option ng-repeat="client in clients" value="{{client.Id}}">{{client.Name}}</option>
</select>
But the error I'm getting seems to indicate that this JSON is being interpreted improperly:
Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed.
Use 'track by' expression to specify unique keys.
Repeater: client in clients track by client.Id,
Duplicate key: undefined, Duplicate value: "["
It's that last line that's throwing me off - duplicate value "["
Here's the controller code. Pretty straightforward:
[HttpGet]
public string GetAll()
{
return JsonConvert.SerializeObject(clientRepo.GetAll(),
Formatting.Indented,
new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
}
Do I need to take an extra formatting step before I return the JSON object?