Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create JSON configuration from string using Apache commons configuration

Is it possible to create a JSON configuration form a String in Apache commons configuration so that I can get some values from it?

For example, if I'd have a String containing this configuration, I'd like to be able to convert it into an org.apache.commons.configuration2.json.JSONConfiguration so that I can get values from it with the getX(nodeName) method (ex.: config.getInt("sectionA.valueB") would return 332):

{sectionA:{valueA:true, valueB:332}, sectionB:{valueA:124, valueB:"abc"}}

Would I have to wrap the string in something such as a Reader so that I can use the configuration's load(Reader) method? If yes, what would be the shortest and fastest way to do that?


1 Answers

I'd much rather use JSON than XML, but short of writing my own JSON shim for the library, I don't see any 'built in' solution.

like image 127
Evvo Avatar answered Apr 20 '26 19:04

Evvo