Returns a json stream that wraps input object stream
543625
function jsonEncoder(input, path) {
    var output = new Stream();
    output.readable = true;
    var first = true;
    input.on("data", function (entry) {
      if (path) {
        entry.href = path + entry.name;
        var mime = entry.linkStat ? entry.linkStat.mime : entry.mime;
        if (mime && mime.match(/(directory|folder)$/)) {
          entry.href += "/";
        }
      }
      if (first) {
        output.emit("data", "[\n  " + JSON.stringify(entry));
        first = false;
      } else {
        output.emit("data", ",\n  " + JSON.stringify(entry));
      }
    });
    input.on("end", function () {
      if (first) output.emit("data", "[]");
      else output.emit("data", "\n]");
      output.emit("end");
    });
    if (input.pause) {
      output.pause = function () {
        input.pause();
      };
    }
    if (input.resume) {
      output.resume = function () {
        input.resume();
      };
    }
    return output;
  }
793360
function promisify_read_stream() {
    var transformer = function (stream_promise) {
        var res = new PStream();
        res.to = function (dest) {
            when(stream_promise, function (stream) {
                PStream.wrap_read_stream(stream).to(dest);
            }, function (err) {
                dest.error(err);
            });
        };
        return res.sanitize();
    };

    transformer.for_property = function (obj_promise, prop) {
        return transformer(when(obj_promise, function (obj) {
            return obj[prop];
        }));
    };

    return transformer;
}
1059496
def stream_object_data(self, ref):
		""""""
		cmd = self.__get_persistent_cmd("cat_file_all", "cat_file", batch=True)
		hexsha, typename, size = self.__get_object_header(cmd, ref)
		return (hexsha, typename, size, self.CatFileContentStream(size, cmd.stdout))
400248
private static JsonStructure toJson( TupleRef tuple)
    {
    JsonObjectBuilder builder = Json.createObjectBuilder();

    toStream( tuple.getVarBindings()).forEach( binding -> builder.add( binding.getVar(), String.valueOf( binding.getValue())));
    
    return builder.build();
    }
96144
def _tostream(parser, obj, stream, skipprepack = False):
    
    if hasattr(parser, 'tostream'):
        return parser.tostream(obj, stream, skipprepack)
    else:
        data = parser.tobytes(obj, skipprepack)
        cls = type(parser)
        if cls not in _deprecated_parsers:
            _deprecated_parsers.add(cls)
            warnings.warn("Parser %r does not have 'tostream' interfaces" % (cls,), UserWarning)
        return stream.write(data)
540942
function Stream( value, options ) {
		if ( !arguments.length ) {
			throw new Error( 'Stream()::insufficient input arguments. Must provide a value to append.' );
		}
		if ( arguments.length < 2 ) {
			options = {};
		}
		if ( !( this instanceof Stream ) ) {
			return new Stream( value, options );
		}
		var err = validate( options );
		if ( err ) {
			throw err;
		}

		Transform.call( this, options );
		this._val = value.toString();
		this._destroyed = false;

		return this;
	}
508412
def wrap_json(cls, json):
        
        u = User(usertype=json['type'],
                 name=json['name'],
                 logo=json['logo'],
                 twitchid=json['_id'],
                 displayname=json['display_name'],
                 bio=json['bio'])
        return u
63887
private static String jsonEncode(Object object) throws IOException {
      
      ObjectMapper mapper = new ObjectMapper();
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      try {
         mapper.writeValue(outputStream, object);
         return new String(outputStream.toByteArray());
      } catch (JsonGenerationException e) {
         logger.severe("unable encode");
         throw new IOException(e);
      } catch (JsonMappingException e) {
         logger.severe("unable encode");
         throw new IOException(e.getMessage());
      }
      
   }
167741
def FromData(cls, stream, json_data, http, auto_transfer=None,
                 gzip_encoded=False, **kwds):
        """"""
        info = json.loads(json_data)
        missing_keys = cls._REQUIRED_SERIALIZATION_KEYS - set(info.keys())
        if missing_keys:
            raise exceptions.InvalidDataError(
                'Invalid serialization data, missing keys: %s' % (
                    ', '.join(missing_keys)))
        if 'total_size' in kwds:
            raise exceptions.InvalidUserInputError(
                'Cannot override total_size on serialized Upload')
        upload = cls.FromStream(stream, info['mime_type'],
                                total_size=info.get('total_size'),
                                gzip_encoded=gzip_encoded, **kwds)
        if isinstance(stream, io.IOBase) and not stream.seekable():
            raise exceptions.InvalidUserInputError(
                'Cannot restart resumable upload on non-seekable stream')
        if auto_transfer is not None:
            upload.auto_transfer = auto_transfer
        else:
            upload.auto_transfer = info['auto_transfer']
        upload.strategy = RESUMABLE_UPLOAD
        upload._Initialize(  # pylint: disable=protected-access
            http, info['url'])
        upload.RefreshResumableUploadState()
        upload.EnsureInitialized()
        if upload.auto_transfer:
            upload.StreamInChunks()
        return upload
974080
def wrap_json_body(func=None, *, preserve_raw_body=False):
    

    if func is None:
        return functools.partial(
            wrap_json_body,
            preserve_raw_body=preserve_raw_body
        )

    @functools.wraps(func)
    def wrapper(request, *args, **kwargs):
        ctype, pdict = parse_header(request.headers.get('Content-Type', ''))
        if preserve_raw_body:
            request.raw_body = request.body
        if ctype == "application/json":
            request.body = json.loads(request.body.decode("utf-8")) if request.body else None
        return func(request, *args, **kwargs)
    return wrapper
573859
def handle_json_wrapper_GET(self, handler, parsed_params):
    """"""
    schedule = self.server.schedule
    result = handler(parsed_params)
    content = ResultEncoder().encode(result)
    self.send_response(200)
    self.send_header('Content-Type', 'text/plain')
    self.send_header('Content-Length', str(len(content)))
    self.end_headers()
    self.wfile.write(content)
951099
function serialize(input) {
    const value = JSON.stringify(input);
    return value === undefined
        ? reject(new Error(`Unsupported type ${type(input)}`))
        : resolve(value);
}
1218037
def dumps(obj, *args, **kwargs):
    '''  '''
    return json.dumps(obj, *args, cls=TypelessSONEncoder, ensure_ascii=False, **kwargs)
736778
def json_serial(obj):
    """"""

    if isinstance(obj, (datetime, date)):
        serial = obj.isoformat()
        return serial

    from ..time_interval import TimeInterval, TimeIntervals
    if isinstance(obj, (TimeInterval, TimeIntervals)):
        return obj.to_json()

    from ..stream import StreamId
    if isinstance(obj, StreamId):
        return obj.to_json()

    from ..channels import BaseChannel
    if isinstance(obj, BaseChannel):
        return json.dumps({'channel_id': obj.channel_id})

    raise TypeError("Type %s not serializable" % type(obj))
922018
function Stream( options ) {
	var args = arguments,
		opts = {},
		err;
	if ( args.length ) {
		opts = options;
	}
	if ( !( this instanceof Stream ) ) {
		return new Stream( opts );
	}
	err = validate( opts );
	if ( err ) {
		throw err;
	}
	Transform.call( this, opts );
	this._readableState.objectMode = true;
	this._data = '';

	return this;
}
771981
def items(stream, **kwargs):
    
    for s in yield_json(stream):
        yield json.loads(s, **kwargs)
492998
public JSONObject instantiateJsonObject(InputStream in) throws IOException,
                                                                JSONException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    StringBuffer contents = new StringBuffer();
    String text = null;
    while ((text = reader.readLine()) != null) {
      contents.append(text).append(System.getProperty("line.separator"));
    }
    in.close();
    JSONObject json = new JSONObject(contents.toString());
    return json;
  }