1

I am trying to pass data to a REST service from .Net and the format required by the service is similar to JSON but more like straight JavaScript.

For example:

{ name:'Test User', first_name:'Test', last_name:'User'}

Without the key quoted or using full quotes on the string values it doesn't exactly align with the JSON spec and the serializers like JSON.NET don't output in this format. I have tried sending straight up JSON to no avail.

Is there another serializer anyone is aware of that will handle this, or a way to customize the output of something like JSON.NET? I'm basically trying to avoid writing my own.

Dayan
  • 7,634
  • 11
  • 49
  • 76
Matt
  • 2,891
  • 2
  • 13
  • 4

1 Answers1

0

Not the most graceful way to do it, but you could always consider using JSON.NET, serializing your object to a JSON string, then performing string manipulation on the output to get it into the format you desire. I'm sure you could write up a quick method that will take in a JSON string and spit it out in a REST service compatible format. That way you don't exactly have to write your own serializer.

Jason Higgins
  • 1,516
  • 1
  • 17
  • 37