Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse properties to Map<String, Object> #376

Open
CarltonX opened this issue Jan 31, 2023 · 1 comment
Open

Parse properties to Map<String, Object> #376

CarltonX opened this issue Jan 31, 2023 · 1 comment
Labels
Properties Issue related to (Java) Properties format backend

Comments

@CarltonX
Copy link

CarltonX commented Jan 31, 2023

When I want to parse properties into Map<String, Object>, the result is not what I want

Code like :

JavaPropsMapper mapper = JacksonMapperHolder.getJavaPropsMapper();

Map<String, Object> result =   mapper.readValue("level1=value1\nlevel1.level2=value2", new TypeReference<Map<String, Object>>() {});

result is
image

but i think it will be

{"level1":"value1","level1.level2":"value2"}

I'm not sure if such a result is correct

@cowtowncoder cowtowncoder added the Properties Issue related to (Java) Properties format backend label Feb 2, 2023
@cowtowncoder
Copy link
Member

cowtowncoder commented Feb 2, 2023

Input is somewhat problematic because for value level1 you would try to add both String value value AND Object value that contains entry level2. So what I would probably except would actually be something like:

{ "level1" : 
    { "level2" : "value" }
}

because second entry would replace first one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Properties Issue related to (Java) Properties format backend
Projects
None yet
Development

No branches or pull requests

2 participants