# Path: piped/processors/json_processors.py
# class JsonDecoder(base.InputOutputProcessor):
# class JsonEncoder(base.InputOutputProcessor):
# class JSONPEncoder(JsonEncoder):
#     def __init__(self, decoder='json.JSONDecoder', **kw):
#     def process_input(self, input, baton):
#     def __init__(self, encoder='piped.util.PipedJSONEncoder', indent=None, **kw):
#     def process_input(self, input, baton):
#     def __init__(self, callback=yamlutil.BatonPath('callback'), fallback_to_json=True, **kw):
#     def process_input(self, input, baton):


import json
import StringIO
from twisted.internet import defer
from twisted.python import reflect
from twisted.trial import unittest
from piped.processors import json_processors
# Copyright (c) 2011, Found IT A/S and Piped Project Contributors.
# See LICENSE for details.




class StubDecoder(json.JSONDecoder):
    """ A custom decoder that doubles any decoded values. """
    def __init__(self, **kwargs):
        kwargs['object_hook'] = self.dict_to_object
        super(StubDecoder, self).__init__(**kwargs)

    def dict_to_object(self, dict_like):
        return dict([(key, value*2) for key, value in dict_like.items()])


class StubEncoder(json.JSONEncoder):

    def encode(self, o):
        return 'custom encoder'


class JsonDecoderTest(unittest.TestCase):

    @defer.inlineCallbacks
    def test_simple_decoding(self):

# Path: piped/processors/json_processors.py
# class JsonDecoder(base.InputOutputProcessor):
# class JsonEncoder(base.InputOutputProcessor):
# class JSONPEncoder(JsonEncoder):
#     def __init__(self, decoder='json.JSONDecoder', **kw):
#     def process_input(self, input, baton):
#     def __init__(self, encoder='piped.util.PipedJSONEncoder', indent=None, **kw):
#     def process_input(self, input, baton):
#     def __init__(self, callback=yamlutil.BatonPath('callback'), fallback_to_json=True, **kw):
#     def process_input(self, input, baton):


# Path: piped/processors/test/test_json_processors.py
import json
import StringIO
from twisted.internet import defer
from twisted.python import reflect
from twisted.trial import unittest
from piped.processors import json_processors

# Copyright (c) 2011, Found IT A/S and Piped Project Contributors.
# See LICENSE for details.




class StubDecoder(json.JSONDecoder):
    """ A custom decoder that doubles any decoded values. """
    def __init__(self, **kwargs):
        kwargs['object_hook'] = self.dict_to_object
        super(StubDecoder, self).__init__(**kwargs)

    def dict_to_object(self, dict_like):
        return dict([(key, value*2) for key, value in dict_like.items()])


class StubEncoder(json.JSONEncoder):

    def encode(self, o):
        return 'custom encoder'


class JsonDecoderTest(unittest.TestCase):

    @defer.inlineCallbacks
    def test_simple_decoding(self):

        processor = json_processors.JsonDecoder()