0

I'm taking my first stab at Asp.Net Web API and MVC to retrieve JSON results. When I query the controller, I receive the following JSON set:

[{"date":"2013-05-01T10:00:00","value":1445.95},{"date":"2013-05-01T10:05:00","value":1427.42}]

However, these results include name:value pairs. I would prefer to receive an ordered results array (with no names):

[{"2013-05-01T10:00:00",1445.95},{"2013-05-01T10:05:00",1427.42}]

I think I read that this is commonly handled after retrieving the JSON object. In this case though, I'm trying to match the output format of another site's existing REST interface. Any suggestions on how to achieve this output?

1 Answer 1

0

I would prefer to receive an ordered results array (with no names):

[{"2013-05-01T10:00:00",1445.95},{"2013-05-01T10:05:00",1427.42}]

Sorry but your desired output is invalid JSON. Check it on http://jsonlint.com and see for yourself. I am afraid that if you want to produce such string (because this is not JSON) you will have to build it manually by yourself. The JSON serializer in the Web API produces only JSON.

In this case though, I'm trying to match the output format of another site's existing REST interface.

I would be extremely surprised if a site is using this string as output format. If it is I would suggest you contacting the authors of this service alerting them that this is not JSON.

1
  • That's what I suspected. I was hoping I was wrong. I'll have to follow up with the other site's authors. Thanks for the syntax link!
    – MTAdmin
    Commented Jul 17, 2013 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.