.Net version 4.5.
I have an object called Process and under that I have collection of Activities
{
“processDocument”: [
{
“jsonapi”: {“version”: “1.1”},
“data”: {
“type”: “process-model”,
“id”: “510003”,
“attributes”: {
“process-id”: 510003,
“process-name”: “Process123”,
“enabled”: true,
“activities”: [
{
“processId”: 510003,
“activityId”: 510005,
“activityName”: “Activity 1”
},
{
“processId”: 510003,
“activityId”: 510054,
“activityName”: “Activity 2”
},
{
“processId”: 510003,
“activityId”: 510004,
“activityName”: “Activity 3”
}
]
}
}
}
]
}
Here’s what I’m trying to accomplish:
I want to be able to get the fully qualified links for each item in the activity collection. I’m able to output the above json without links by this code:
var processdoc = documentContext
.NewDocument(HttpContext.Current.Request.Url)
.SetJsonApiVersion(JsonApiVersion.Version11)
.Resource(process)
.ResourceEnd()
.WriteDocument();
The “process” object supplied to the Resource() method above contains the Process properties and a collection (List) of activities. The JSON Api doesn’t seem to support accessing collection the ResourceCollection() under Resource()… I was expecting to do something like this:
var processdoc = documentContext
.NewDocument(HttpContext.Current.Request.Url)
.SetJsonApiVersion(JsonApiVersion.Version11)
.Resource(process)
.ResourceCollection(process.Activities)
.Links()
.AddSelfLink()
.LinksEnd()
.ResourceCollectionEnd()
.ResourceEnd()
.WriteDocument();
Or is there some other way to accomplish this using JSON Api that I’m not aware of?
I was also hoping to convert the property name to camel case (processId, processName) instead of using hyphens (process-id, process-name) in the JSON output. Is that doable in JSON Api?
Appreciate any help on these.
Vin