<NME> json_lines.rb
<BEF> ADDFILE
<MSG> Break out json into json_lines so that users streaming json can use the line delimited codec and users using message based transports i.e. redis can still use a codec without requiring the message end in '\n'

<DFF> @@ -0,0 +1,51 @@
+require "logstash/codecs/json_lines"
+require "logstash/event"
+require "insist"
+
+describe LogStash::Codecs::JSONLines do
+  subject do
+    next LogStash::Codecs::JSONLines.new
+  end
+
+  context "#decode" do
+    it "should return an event from json data" do
+      data = {"foo" => "bar", "baz" => {"bah" => ["a","b","c"]}}
+      subject.decode(data.to_json+"\n") do |event|
+        insist { event.is_a? LogStash::Event }
+        insist { event["foo"] } == data["foo"]
+        insist { event["baz"] } == data["baz"]
+        insist { event["bah"] } == data["bah"]
+      end
+    end
+    
+    it "should return an event from json data when a newline is recieved" do
+      data = {"foo" => "bar", "baz" => {"bah" => ["a","b","c"]}}
+      subject.decode(data.to_json) do |event|
+        insist {false}
+      end
+      subject.decode("\n") do |event|
+        insist { event.is_a? LogStash::Event }
+        insist { event["foo"] } == data["foo"]
+        insist { event["baz"] } == data["baz"]
+        insist { event["bah"] } == data["bah"]
+      end
+    end
+  end
+
+  context "#encode" do
+    it "should return json data" do
+      data = {"foo" => "bar", "baz" => {"bah" => ["a","b","c"]}}
+      event = LogStash::Event.new(data)
+      got_event = false
+      subject.on_event do |d|
+        insist { d.chomp } == LogStash::Event.new(data).to_json
+        insist { JSON.parse(d)["foo"] } == data["foo"]
+        insist { JSON.parse(d)["baz"] } == data["baz"]
+        insist { JSON.parse(d)["bah"] } == data["bah"]
+        got_event = true
+      end
+      subject.encode(event)
+      insist { got_event }
+    end
+  end
+end

Break out json into json_lines so that users streaming json can use the line delimited codec and users using message based transports i.e. redis can still use a codec without requiring the message end in '\n'