From 1a23579acc10ea56b5f6350ed53f84f74ef271b8 Mon Sep 17 00:00:00 2001 From: Maksim Grishkin Date: Sat, 27 Jan 2024 15:38:02 +0300 Subject: [PATCH] fix(JmesPath): Allows key names to be written using the Russian alphabet Doesn't fix the issue with the entire Unicode character set supported by Json. Therefore, it needs to be improved in the future. --- src/JsonCons.JmesPath/JmesPathParser.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/JsonCons.JmesPath/JmesPathParser.cs b/src/JsonCons.JmesPath/JmesPathParser.cs index 9ac2661..1983e5a 100644 --- a/src/JsonCons.JmesPath/JmesPathParser.cs +++ b/src/JsonCons.JmesPath/JmesPathParser.cs @@ -322,7 +322,9 @@ internal JsonTransformer Parse() ++_column; break; default: - if ((_span[_index] >= 'A' && _span[_index] <= 'Z') || (_span[_index] >= 'a' && _span[_index] <= 'z') || (_span[_index] == '_')) + if (_span[_index] == '_' + || (_span[_index] >= 'A' && _span[_index] <= 'Z') || (_span[_index] >= 'a' && _span[_index] <= 'z') + || (_span[_index] >= 'А' && _span[_index] <= 'Я') || (_span[_index] >= 'а' && _span[_index] <= 'я') || _span[_index] == 'ё' || _span[_index] == 'Ё') { _stateStack.Pop(); _stateStack.Push(JmesPathState.IdentifierOrFunctionExpr); @@ -374,7 +376,9 @@ internal JsonTransformer Parse() ++_column; break; default: - if ((_span[_index] >= 'A' && _span[_index] <= 'Z') || (_span[_index] >= 'a' && _span[_index] <= 'z') || (_span[_index] == '_')) + if (_span[_index] == '_' + || (_span[_index] >= 'A' && _span[_index] <= 'Z') || (_span[_index] >= 'a' && _span[_index] <= 'z') + || (_span[_index] >= 'А' && _span[_index] <= 'Я') || (_span[_index] >= 'а' && _span[_index] <= 'я') || _span[_index] == 'ё' || _span[_index] == 'Ё') { _stateStack.Pop(); _stateStack.Push(JmesPathState.IdentifierOrFunctionExpr); @@ -520,7 +524,9 @@ internal JsonTransformer Parse() SkipWhiteSpace(); break; default: - if ((_span[_index] >= '0' && _span[_index] <= '9') || (_span[_index] >= 'A' && _span[_index] <= 'Z') || (_span[_index] >= 'a' && _span[_index] <= 'z') || (_span[_index] == '_')) + if (_span[_index] == '_' || (_span[_index] >= '0' && _span[_index] <= '9') + || (_span[_index] >= 'A' && _span[_index] <= 'Z') || (_span[_index] >= 'a' && _span[_index] <= 'z') + || (_span[_index] >= 'А' && _span[_index] <= 'Я') || (_span[_index] >= 'а' && _span[_index] <= 'я') || _span[_index] == 'ё' || _span[_index] == 'Ё') { buffer.Append(_span[_index]); ++_index; @@ -1101,7 +1107,9 @@ internal JsonTransformer Parse() ++_column; break; default: - if ((_span[_index] >= 'A' && _span[_index] <= 'Z') || (_span[_index] >= 'a' && _span[_index] <= 'z') || (_span[_index] == '_')) + if (_span[_index] == '_' + || (_span[_index] >= 'A' && _span[_index] <= 'Z') || (_span[_index] >= 'a' && _span[_index] <= 'z') + || (_span[_index] >= 'А' && _span[_index] <= 'Я') || (_span[_index] >= 'а' && _span[_index] <= 'я') || _span[_index] == 'ё' || _span[_index] == 'Ё') { _stateStack.Pop(); _stateStack.Push(JmesPathState.ExpectColon);