code: def conv_to_json(obj, fields=None):
          
          if fields is None:
              return json_encode(OrderedDict(((x, obj[x]) for x in obj if not x.startswith('_')))) + '\n'
  
          result = json_encode(OrderedDict([(x, obj[x]) for x in fields if x in obj])) + '\n'
  
          return result
docs: return cdx as json dictionary string
          if ``fields`` is ``None``, output will include all fields
          in order stored, otherwise only specified fields will be
          included
  
          :param fields: list of field names to output