chimpler / pyhocon

HOCON parser for Python
Apache License 2.0
506 stars 119 forks source link

Empty string key not supported #261

Open yunjiangster opened 3 years ago

yunjiangster commented 3 years ago

I am using the latest pyhocon and it fails to parse the simplest json dictionary with empty string:

import pyhocon
from pyhocon import ConfigFactory
ConfigFactory.parse_string('{"": ""}')

Traceback (most recent call last): ... assert key_index < len(key_path), (key_index, key_path, self) AssertionError: (0, [], ConfigTree())

On the other hand, json handles it perfectly fine.

import json
json.loads('{"": ""}')

{'': ''}

Thanks for your attention. I am surprised this simple issue hasn't been raised before.

pip show pyhocon

Name: pyhocon Version: 0.3.57

python --version

Python 3.6.5

cat /etc/os-release

NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"

polopi commented 3 years ago

Same issue