Skip to content

Merge part of #471 ahead of it (to reduce diff) #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1021,12 +1021,7 @@ protected JsonToken _handleNamedValue() throws IOException
}
}
_state = STATE_NEXT_ENTRY;
if (_nullValue != null) {
if (_nullValue.equals(_currentValue)) {
return JsonToken.VALUE_NULL;
}
}
if (_cfgEmptyStringAsNull && "".equals(_currentValue)) {
if (_isNullValue(_currentValue)) {
return JsonToken.VALUE_NULL;
}
return JsonToken.VALUE_STRING;
Expand All @@ -1048,12 +1043,7 @@ protected JsonToken _handleUnnamedValue() throws IOException
// state remains the same
_currentValue = next;
++_columnIndex;
if (_nullValue != null) {
if (_nullValue.equals(next)) {
return JsonToken.VALUE_NULL;
}
}
if (_cfgEmptyStringAsNull && "".equals(_currentValue)) {
if (_isNullValue(next)) {
return JsonToken.VALUE_NULL;
}
return JsonToken.VALUE_STRING;
Expand Down Expand Up @@ -1093,12 +1083,7 @@ protected JsonToken _handleArrayValue() throws IOException
if (isEnabled(Feature.TRIM_SPACES)) {
_currentValue = _currentValue.trim();
}
if (_nullValue != null) {
if (_nullValue.equals(_currentValue)) {
return JsonToken.VALUE_NULL;
}
}
if (_cfgEmptyStringAsNull && "".equals(_currentValue)) {
if (_isNullValue(_currentValue)) {
return JsonToken.VALUE_NULL;
}
return JsonToken.VALUE_STRING;
Expand Down Expand Up @@ -1448,4 +1433,23 @@ protected void _startArray(CsvSchema.Column column)
}
_arraySeparator = sep;
}


/**
* Helper method called to check whether specified String value should be considered
* "null" value, if so configured.
*
* @since 2.17.1
*/
protected boolean _isNullValue(String value) {
if (_nullValue != null) {
if (_nullValue.equals(value)) {
return true;
}
}
if (_cfgEmptyStringAsNull && _currentValue.isEmpty()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_currentValue here is wrong: fixed in next commit.

return true;
}
return false;
}
}