PowerJSON
PowerJSON copied to clipboard
recommended way to embed JSON string
I'm looking for the recommended way to deal with this issue using PowerJSON: Suppose I want a single object that has a method name and its parameters. In order to deserialize the parameters, I need to know what the method is. Hence I want to be able to (de)serialize in two phases, the outer object before the inner object. I can do this in Json.NET using the JObject stuff. This approach works:
class MyMethod { public string Method {get;set;} public JArray Parameters {get;set;} // using Json.NET LINQ object }
That allows me to serialize the parameters and then serialize the entire class with the parameters being a simple embedded object. I would like some way to do that with this serializer. I need some data type that the serializer treats as "embedded JSON object". I can use a string (or an array of), but then will be encoded. That seems expensive to me.