0

I have a component that acts as a middle man between 2 web services. Both of them communicate using JSON.

The data that goes back and forth from the web services is very similar. However, it does need to be massaged a little.

I currently have this working by deserializing the JSON, build a new JObject and serialize it. It seems like there should be better way.

I'm looking at JsonConvert, JsonConverter, JsonSerializer, JsonReader, etc. trying to see if there's a better way to do this.

Any guidance on what classes to use/override to make this process more efficent?

Thanks!

3
  • 2
    Provide a minimal reproducible example that reproduces issue so that it can be analyzed and a potential solution derived. Commented Nov 21, 2016 at 17:14
  • 1
    You write, It seems like there should be better way. What exactly is the problem with the current way you are doing things? Excessive memory use dealing with huge JSON payloads? Performance? Maintainability? Commented Nov 21, 2016 at 17:41
  • How different are the JSON structures that both sides need? Can you maybe show some samples of the JSON and the code you are using to do the translation? Commented Nov 22, 2016 at 15:51

1 Answer 1

1

You can write a custom JsonConverter using the approach described in the documentation, so you'll only have one concrete class, but this class can translate to a slightly different JSON representation of your object.

Another, more verbose, blog post about writing custom JsonConverters can be found here: http://blog.maskalik.com/asp-net/json-net-implement-custom-serialization/

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.