Web Connection
Best practices for using wwJsonSerializer
Gravatar is a globally recognized avatar based on your email address. Best practices for using wwJsonSerializer
  Richard Kaye
  All
  Dec 19, 2019 @ 01:06pm

Hi all,

I'm building a class to generate json objects using wwJsonSerializer. In this class I have various methods for handling different bits of the data crunching. Is it better to have a single wwJsonSerializer object that is in scope at my class object level to handle all serializing of my json data or is instantiating a local serializer inside each method that needs to perform serializing functions?

TIA

Gravatar is a globally recognized avatar based on your email address. re: Best practices for using wwJsonSerializer
  Rick Strahl
  Richard Kaye
  Dec 20, 2019 @ 01:51am

I don't think it matters in terms of performance since the class is pretty low in overhead.

However, personally I prefer to create new objects simply because it makes sure I start from a clean state. If you reuse you may have to reset Property overrides or other customized settings, so I'd think it's better to just create new instances each time and set your settings each time (or through a centralized helper).

+++ Rick ---

© 1996-2025