mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed JSON datatype string parse
This commit is contained in:
@@ -158,7 +158,7 @@ public class JsonConversion {
|
||||
throw new IllegalArgumentException("illegal json data");
|
||||
}
|
||||
return new Json_Value(Json_enum_type.STRING,
|
||||
buffer.rewind().forward((int) n).getFixStringIgnore0000((int) str_len, charset));
|
||||
buffer.rewind().forward((int) n).getFixLengthString((int) str_len, charset));
|
||||
case JSONB_TYPE_OPAQUE:
|
||||
/*
|
||||
* There should always be at least one byte, which tells the field type of the
|
||||
@@ -257,7 +257,7 @@ public class JsonConversion {
|
||||
// entry, always two
|
||||
// bytes.
|
||||
long key_length = m_data.getUint16();
|
||||
return m_data.rewind().forward((int) key_offset).getFixStringIgnore0000((int) key_length, charset);
|
||||
return m_data.rewind().forward((int) key_offset).getFixLengthString((int) key_length, charset);
|
||||
}
|
||||
|
||||
public Json_Value element(int i, Charset charset) {
|
||||
@@ -400,7 +400,7 @@ public class JsonConversion {
|
||||
}
|
||||
buf.append('"').append(text).append('"');
|
||||
} else {
|
||||
text = m_data.getFixStringIgnore0000((int) m_length, charset);
|
||||
text = m_data.getFixLengthString((int) m_length, charset);
|
||||
buf.append('"').append(escapse(text)).append('"');
|
||||
}
|
||||
|
||||
|
||||
@@ -1157,9 +1157,10 @@ public class LogBuffer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next fix length string from buffer. ignore \0
|
||||
* Return next fix length string from buffer.
|
||||
* see json_binary.cc read_variable_length
|
||||
*/
|
||||
public final String getFixStringIgnore0000(final int len, Charset charset) {
|
||||
public final String getFixLengthString(final int len, Charset charset) {
|
||||
if (position + len > origin + limit) {
|
||||
throw new IllegalArgumentException("limit excceed: " + (position + len - origin));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user