Google.Protobuf.JsonFormatter.ToCamelCaseForFieldMask C# (CSharp) Method

ToCamelCaseForFieldMask() private static method

Camel-case converter with added strictness for field mask formatting.
The field mask is invalid for JSON representation
private static ToCamelCaseForFieldMask ( string input ) : string
input string
return string
        private static string ToCamelCaseForFieldMask(string input)
        {
            for (int i = 0; i < input.Length; i++)
            {
                char c = input[i];
                if (c >= 'A' && c <= 'Z')
                {
                    throw new InvalidOperationException($"Invalid field mask to be converted to JSON: {input}");
                }
                if (c == '_' && i < input.Length - 1)
                {
                    char next = input[i + 1];
                    if (next < 'a' || next > 'z')
                    {
                        throw new InvalidOperationException($"Invalid field mask to be converted to JSON: {input}");
                    }
                }
            }
            return ToCamelCase(input);
        }