1

Is there any way to have Json.net serialize an object directly to a NetworkStream?

In other words, have Json.net send the serialized result to the network as it serializes the object (in a streaming fashion).

I would like to avoid having to serialize the object to memory and then send it via the NetworkStream.

Any thoughts?

Regards

1 Answer 1

1

You can create a TextWriter on top of a NetworkStream, and serialize to the TextWriter; or you can create a JsonTextWriter on top of a TextWriter and serialize to that.

You don't need to serialize to, say, a temporary string or byte array first.

Sign up to request clarification or add additional context in comments.

Comments

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.