Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

null without a comma at the end is Hocon::String("null"), not Hocon::null #69

Open
35VLG84 opened this issue Jan 21, 2023 · 0 comments
Open

Comments

@35VLG84
Copy link

35VLG84 commented Jan 21, 2023

Hello,
First of all, Thank You very much for implementing HOCON for rust!

There seem to be a following anomaly with null-values: If there isn't a comma after null value, it's interpreted as Hocon::String("null"), instead of Hocon::Null. By specification both cases should be null. This is also how Config does it (both are nulls), so this seems to be a bug.

use hocon::{Hocon, HoconLoader, Error};

fn check_null(doc: &Hocon) {
   match doc {
        Hocon::Null => {
            println!("It's null!");
        }
        _ => {
            println!("{:#?}", doc);
            panic!();
        }
   }
}

fn main() -> Result<(), Error> {
    // this works
    //let example = r#"{ null_with_comma = null, a { a_null = null, } }"#;
    let example   = r#"{ null_with_comma = null, a { a_null = null  } }"#;

    let doc = HoconLoader::new().load_str(example)?.hocon()?;

    check_null(&doc["null_with_comma"]);

    check_null(&doc["a"]["a_null"]);
    Ok(())
}

I'm planning to use hocon.rs for one project and noticed this while preparing an RFC pull request for hocon.rs. I will open the RFC pull request soon, so we can discuss about it separately.

@35VLG84 35VLG84 changed the title Wrong handling of null values: null without a comma at the is String("null") Wrong handling of null values: null without a comma at the end is String("null") Jan 21, 2023
@35VLG84 35VLG84 changed the title Wrong handling of null values: null without a comma at the end is String("null") null without a comma at the end is Hocon::String("null"), not Hocon::null Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant