@Test public void testHasJsonElementCaseInsensitive() { final String json = "{\"REPLY\":{\"" + F8_FIELD.getName() + "\":2.025000}}"; final Record record = mockRecord("reply", mockStructure(F8_FIELD)); RecordWriter.putFromJson(json, record); verify(record, times(1)).setF8(F8_FIELD.getName(), 2.025); }
public static void putFromJson(final String json, final Record record) { final JsonObject jsonObject = gson.fromJson(json, JsonObject.class); final String recordNameUpper = record.getName().toUpperCase(Locale.getDefault()); if (!jsonObject.has(recordNameUpper)) throw new IllegalArgumentException("JSON does not contain record " + recordNameUpper); putFromJsonObject(jsonObject.getAsJsonObject(recordNameUpper), record); }
RecordWriter { public static void putFromJson(final String json, final Record record) { final JsonObject jsonObject = gson.fromJson(json, JsonObject.class); final String recordNameUpper = record.getName().toUpperCase(Locale.getDefault()); if (!jsonObject.has(recordNameUpper)) throw new IllegalArgumentException("JSON does not contain record " + recordNameUpper); putFromJsonObject(jsonObject.getAsJsonObject(recordNameUpper), record); } }
RecordWriter { public static void putFromJson(final String json, final Record record) { final JsonObject jsonObject = gson.fromJson(json, JsonObject.class); final String recordNameUpper = record.getName().toUpperCase(Locale.getDefault()); if (!jsonObject.has(recordNameUpper)) throw new IllegalArgumentException("JSON does not contain record " + recordNameUpper); putFromJsonObject(jsonObject.getAsJsonObject(recordNameUpper), record); }  }
RecordWriter { public static void putFromJson(final String json, final Record record) { final JsonObject jsonObject = gson.fromJson(json, JsonObject.class); final String recordNameUpper = record.getName().toUpperCase(Locale.getDefault()); if (!jsonObject.has(recordNameUpper)) throw new IllegalArgumentException("JSON does not contain record " + recordNameUpper); putFromJsonObject(jsonObject.getAsJsonObject(recordNameUpper), record); }  static void putFromJson(final String json, final Record record); }
RecordWriter { public static void putFromJson(final String json, final Record record) { final JsonObject jsonObject = gson.fromJson(json, JsonObject.class); final String recordNameUpper = record.getName().toUpperCase(Locale.getDefault()); if (!jsonObject.has(recordNameUpper)) throw new IllegalArgumentException("JSON does not contain record " + recordNameUpper); putFromJsonObject(jsonObject.getAsJsonObject(recordNameUpper), record); }  static void putFromJson(final String json, final Record record);  }