You are right, the string you mentioned is malformed JSON, and won't be parsed by any JSON parser. The line you mentioned should have escaped the double quotes in the value like this:
..."patient_name" : "Bobby ack \"bob\" Kaylab", "patient_id"...
Without control over the incoming message, you can always wrap the parse in a try catch. If it fails to parse, you can try to manually correct it and then parse again. Change your source node to Text, and in your first mapping, convert your message to JSON using the following custom Mapping:
try {
message = qie.createJSONMessage(source.getNode("/"), "UTF-8");
} catch (err) {
var malformedJson = source.toString();
var builder = new java.lang.StringBuilder();
var commaSplit = StringUtils.splitByWholeSeparator(malformedJson, ',');
// split on ,
for (var i = 0; i < commaSplit.length; i++) {
// split on :
var colonSplit = StringUtils.splitByWholeSeparatorPreserveAllTokens(commaSplit[i], ':');
for (var j = 0; j < colonSplit.length; j++) {
var quoteSplit = StringUtils.splitByWholeSeparatorPreserveAllTokens(colonSplit[j], '"');
if (quoteSplit.length > 2) {
// escape any double-quotes between the first and the last double-quotes
builder.append(quoteSplit[0])
.append('"')
.append(StringUtils.join(quoteSplit, "\\\"", 1, quoteSplit.length - 1))
.append('"')
.append(quoteSplit[quoteSplit.length - 1]);
} else {
builder.append(colonSplit[j]);
}
if (j < colonSplit.length - 1) {
builder.append(":");
}
}
// join with ,
if (i < commaSplit.length - 1) {
builder.append(",");
}
}
qie.debug(builder.toString());
message = qie.parseJSONString(builder.toString(), "UTF-8");
This solution is not perfect. Your string would still fail if there is unescaped quotes and commas or colons in the value. We are trying to salvage malformed JSON to begin with.
Also, if these messages error, you can always resubmit erred messages and edit the source with the corrected value.