Config...::Json(3pm)
πΈ Config::Model::Backend::Json πΈ
okay bestie, welcome to the manual page for Config::Model::Backend::Json β which shows up in the header as Config...::Json(3pm) because the terminal is being dramatic and truncating our gorgeous long name π
β¨ NAME β¨
Config::Model::Backend::Json β read and write config as a JSON data structure π«Ά
π VERSION π
version 2.166 β yeah she's got a version number, she's a whole grown-up module β¨
π SYNOPSIS π
okay so first you set up your whole config tree situation:
use Config::Model ;
use Data::Dumper ;
# define configuration tree object
my $model = Config::Model->new ;
$model ->create_config_class (
name => "MyClass",
element => [
[qw/foo bar/] => {
type => 'leaf',
value_type => 'string'
},
baz => {
type => 'hash',
index_type => 'string' ,
cargo => {
type => 'leaf',
value_type => 'string',
},
},
],
rw_config => {
backend => 'Json' ,
config_dir => '/tmp',
file => 'foo.json',
auto_create => 1,
}
) ;
my $inst = $model->instance(root_class_name => 'MyClass' );
my $root = $inst->config_root ;
my $steps = 'foo=yada bar="bla bla" baz:en=hello
baz:fr=bonjour baz:hr="dobar dan"';
$root->load( steps => $steps ) ;
$inst->write_back ;
and like⦠now, "/tmp/foo.yml" contains:
{
"bar" : "bla bla",
"foo" : "yada",
"baz" : {
"hr" : "dobar dan",
"en" : "hello",
"fr" : "bonjour"
}
}
LOOK AT HER GO π₯ that's the whole pipeline and it ate, no cap.
π DESCRIPTION π
So Config::Model uses this module directly to read or write the content of a configuration tree that's written with Json syntax inside a Config::Model configuration tree. That's the whole job, and she does it flawlessly π§
ngl there's a lil quirk you need to know: undefined values get skipped for list element. Like, if a list element contains ('a',undef,'b'), the data structure only contains 'a','b'. undef just doesn't make the cut, sorry bestie π
And heads up β you must install the JSON module to use this backend. no JSON module, no vibes, that's just the deal π
π CONSTRUCTOR π
π¦ new π¦
Parameters: ( node => $node_obj, name => 'Json' )
Inherited from Config::Model::Backend::Any. The constructor gets called by Config::Model::BackendMgr β you don't have to summon it yourself, she comes when she's called β¨
π¦ read π¦
Of all the parameters handed to this read call-back, only file_path is used. That parameter must be a Path::Tiny.
When a file is read, read returns 1. icon behavior, honestly π«Ά
π¦ write π¦
Of all the parameters handed to this write call-back, only file_path is used. That parameter must be a Path::Tiny object.
write returns 1. consistent queen π
β AUTHOR β
Dominique Dumont, (ddumont at cpan dot org)
π SEE ALSO π
Config::Model, Config::Model::BackendMgr, Config::Model::Backend::Any,
β AUTHOR β
Dominique Dumont
(yes bestie, AUTHOR shows up twice, I don't make the rules, I just report them π)
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2005-2022 by Dominique Dumont.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999
and that's the whole page, main character energy from start to finish π this was generated for perl v5.42.3, dated 2026-07-23 β mwah, perfection, periodt π
β¨π
π¦ where this page comes from
- ubuntu stonking: libconfig-model-perl 2.166-1 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms