old_contents: """Priority based json library imports.
  
  Use jsonapi.loads() and jsonapi.dumps() for guaranteed symmetry.
  
  Priority: jsonlib2 > jsonlib > simplejson > json
  
  Ensures bytes instead of unicode on either side of serialization.
  
  Authors
  -------
  * MinRK
  * Brian Granger
  """
  
  #-----------------------------------------------------------------------------
  #  Copyright (c) 2010-2012 Brian Granger, Min Ragan-Kelley
  #
  #  This file is part of pyzmq
  #
  #  Distributed under the terms of the New BSD License.  The full license is in
  #  the file COPYING.BSD, distributed as part of this software.
  #-----------------------------------------------------------------------------
  
  #-----------------------------------------------------------------------------
  # Imports
  #-----------------------------------------------------------------------------
  
  from zmq.utils.strtypes import bytes, unicode
  # priority: jsonlib2 > jsonlib > simplejson > json
  
  jsonmod = None
  
  try:
      import jsonlib2 as jsonmod
  except ImportError:
      try:
          import jsonlib as jsonmod
      except ImportError:
          try:
              import simplejson as jsonmod
          except ImportError:
              try:
                  import json as jsonmod
              except ImportError:
                  pass
  
  def _squash_unicode(s):
      if isinstance(s, unicode):
          return s.encode('utf8')
      else:
          return s
  
  def jsonlib_dumps(o,**kwargs):
      """This one is separate because jsonlib doesn't allow specifying separators.
      See jsonlib.dumps for details on kwargs.
      """
      return _squash_unicode(jsonmod.dumps(o,**kwargs))
  
  def dumps(o, **kwargs):
      """Serialize object to JSON str.
      See %s.dumps for details on kwargs.
      """%jsonmod
      
      return _squash_unicode(jsonmod.dumps(o, separators=(',',':'),**kwargs))
  
  def loads(s,**kwargs):
      """Load object from JSON str.
      See %s.loads for details on kwargs.
      """%jsonmod
      if str is unicode and isinstance(s, bytes):
          s = s.decode('utf8')
      return jsonmod.loads(s,**kwargs)
  
  if jsonmod is not None and jsonmod.__name__== 'jsonlib':
      dumps = jsonlib_dumps
  
  __all__ = ['jsonmod', 'dumps', 'loads']
  
  
new_contents: """Priority based json library imports.
  
  Use jsonapi.loads() and jsonapi.dumps() for guaranteed symmetry.
  
  Priority: simplejson > jsonlib2 > json
  
  Always serializes to bytes instead of unicode for zeromq compatibility.
  
  jsonapi.loads/dumps provide kwarg-compatibility with stdlib json.
  
  To override pyzmq's choice of json library, you can simply override the loads/dumps
  methods, e.g.::
  
      import ujson
      from zmq.utils import jsonapi
      jsonapi.jsonmod = ujson
      # ujson doesn't support the `separators` kwarg we use, so force its own dumps:
      jsonapi.dumps = ujson.dumps
  
  To select the super-fast ujson module.  Note that using a different module such
  as ujson that does not support the same kwargs as stdlib json may break
  compatibility with other tools that depend on this, if used in the same process.
  A safer route is to just serialize your own messages yourself with your favorite
  library.
  
  Authors
  -------
  * MinRK
  * Brian Granger
  """
  
  #-----------------------------------------------------------------------------
  #  Copyright (c) 2010-2012 Brian Granger, Min Ragan-Kelley
  #
  #  This file is part of pyzmq
  #
  #  Distributed under the terms of the New BSD License.  The full license is in
  #  the file COPYING.BSD, distributed as part of this software.
  #-----------------------------------------------------------------------------
  
  #-----------------------------------------------------------------------------
  # Imports
  #-----------------------------------------------------------------------------
  
  from zmq.utils.strtypes import bytes, unicode
  
  jsonmod = None
  
  priority = ['simplejson', 'jsonlib2', 'json']
  for mod in priority:
      try:
          jsonmod = __import__(mod)
      except ImportError:
          pass
      else:
          break
  
  def _squash_unicode(s):
      if isinstance(s, unicode):
          return s.encode('utf8')
      else:
          return s
  
  def dumps(o, **kwargs):
      """Serialize object to JSON bytes.
      See %s.dumps for details on kwargs.
      """ % jsonmod
      
      if 'separators' not in kwargs:
          kwargs['separators'] = (',', ':')
      
      return _squash_unicode(jsonmod.dumps(o, **kwargs))
  
  def loads(s, **kwargs):
      """Load object from JSON str.
      See %s.loads for details on kwargs.
      """ % jsonmod
      
      if str is unicode and isinstance(s, bytes):
          s = s.decode('utf8')
      return jsonmod.loads(s, **kwargs)
  
  __all__ = ['jsonmod', 'dumps', 'loads']
  
  
subject: drop jsonlib from jsonapi