fixed JSON datatype string parse

This commit is contained in:
jianghang.loujh
2025-08-05 14:26:57 +08:00
parent 16831825b8
commit 8523a51623
2 changed files with 6 additions and 5 deletions

View File

@@ -158,7 +158,7 @@ public class JsonConversion {
throw new IllegalArgumentException("illegal json data"); throw new IllegalArgumentException("illegal json data");
} }
return new Json_Value(Json_enum_type.STRING, 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: case JSONB_TYPE_OPAQUE:
/* /*
* There should always be at least one byte, which tells the field type of the * 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 // entry, always two
// bytes. // bytes.
long key_length = m_data.getUint16(); 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) { public Json_Value element(int i, Charset charset) {
@@ -400,7 +400,7 @@ public class JsonConversion {
} }
buf.append('"').append(text).append('"'); buf.append('"').append(text).append('"');
} else { } else {
text = m_data.getFixStringIgnore0000((int) m_length, charset); text = m_data.getFixLengthString((int) m_length, charset);
buf.append('"').append(escapse(text)).append('"'); buf.append('"').append(escapse(text)).append('"');
} }

View File

@@ -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) { if (position + len > origin + limit) {
throw new IllegalArgumentException("limit excceed: " + (position + len - origin)); throw new IllegalArgumentException("limit excceed: " + (position + len - origin));
} }