Skip to content

Accessing array with JSONConfiguration #5157

@klausholstjacobsen

Description

@klausholstjacobsen

Hello
I am getting a SyntaxExcetion when trying to address an array in my json configuration file.
The config:

{ 
"config" : 
  { "prop1" : "value1",
    "prop2" : 10,
    "prop3" : ["element1", "element2" ],
    "prop4" : { 
      "prop5" : false, 
      "prop6" : null 
    }
  }
}

My code:

Poco::AutoPtr<Poco::Util::JSONConfiguration> cfg = new Poco::Util::JSONConfiguration("config.json");
std::string arrProperty = cfg->getString("config.prop3[1]");

I think the best illustration is a screenshot form my debugger immediately before the exception is thrown:

Image

We're trying to get the string "config.prop3[1]".
We have already looped through the "config" token, and are now handling "prop3[1]".
When running NumberParser::parse() on the "num" variable value "prop3[1]" we get the exception.

I think the error is with the matches. num is created from matches[1], but matches only contain 1 entry! matches[1] is thus not valid!

Normally we would expect the global match on index 0, and the group match on index 1. If that were the case there would be no error!

Regards
Klaus

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions