LzoJsonRecordReader extends LzoRecordReader<LongWritable, MapWritable> implements MapredInputFormatCompatible<LongWritable, MapWritable> { public static boolean decodeLineToJson(JSONParser parser, Text line, MapWritable value) { try { JSONObject jsonObj = (JSONObject)parser.parse(line.toString()); if (jsonObj != null) { for (Object key: jsonObj.keySet()) { Text mapKey = new Text(key.toString()); Text mapValue = new Text(); if (jsonObj.get(key) != null) { mapValue.set(jsonObj.get(key).toString()); } value.put(mapKey, mapValue); } } else { LOG.warn("Could not json-decode string: " + line); return false; } return true; } catch (ParseException e) { LOG.warn("Could not json-decode string: " + line, e); return false; } catch (NumberFormatException e) { LOG.warn("Could not parse field into number: " + line, e); return false; } }  @Override synchronized void close(); @Override LongWritable getCurrentKey(); @Override MapWritable getCurrentValue(); @Override void setKeyValue(LongWritable key, MapWritable value); @Override boolean nextKeyValue(); static boolean decodeLineToJson(JSONParser parser, Text line, MapWritable value);  }
@Test public void testNullString() { Text line = new Text("null"); boolean result = LzoJsonRecordReader.decodeLineToJson(new JSONParser(), line, new MapWritable()); assertEquals("Parsing line with contents 'null'", false, result); }