Skip to content

Commit 91bb487

Browse files
author
Eric Wasserman
committed
add requested comment
1 parent f706ce3 commit 91bb487

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/jsonExpressions.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ case class GetJsonObject(json: Expression, path: Expression)
149149

150150
if (parsed.isDefined) {
151151
try {
152+
/* We know the bytes are UTF-8 encoded. Pass a Reader to avoid having Jackson
153+
detect character encoding which could fail for some malformed strings */
152154
Utils.tryWithResource(jsonFactory.createParser(new InputStreamReader(
153155
new ByteArrayInputStream(jsonStr.getBytes), "UTF-8"))) { parser =>
154156
val output = new ByteArrayOutputStream()
@@ -394,6 +396,8 @@ case class JsonTuple(children: Seq[Expression])
394396
}
395397

396398
try {
399+
/* We know the bytes are UTF-8 encoded. Pass a Reader to avoid having Jackson
400+
detect character encoding which could fail for some malformed strings */
397401
Utils.tryWithResource(jsonFactory.createParser(new InputStreamReader(
398402
new ByteArrayInputStream(json.getBytes), "UTF-8"))) {
399403
parser => parseRow(parser, input)

0 commit comments

Comments
 (0)