This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
We're looking to expose some data to a JSON based API. We use JSON.NET for everything else and would like to use it for this too, but it does not seem to work. Are there any approaches to making this work? |
|
|
You will need to use a custom contract resolver within JSON.NET to cover this as the default JSON.NET resolver will ignore most things due to the DataContract markup we have on our base Entity class. See this thread for a code example of what you will need: http://www.mindscapehq.com/forums/thread/309498
|
|
|
Ah! Thanks Jeremy.. This is exactly what I needed to get started. Thank you once again. |
|
|
Using the above EntityContractResolver class, here is how I was able to return the correct JSON from a WebApi2 controller. Notes: 1) vwItemMaster is the Entity from the lightspeed model, which corresponds to a View in the database. 2) I added ID column in the View (since my PK is not called ID), so I had to comment out the "contract.Properties.Add(new JsonProperty()" line in the above EntityContractResolver class.
HTH |
|