T
Ted Zlatanov
I'm trying to describe a function's data interface through a simple JSON
language (a sort of DSL). Yes, this is a lot like an IDL. For instance
this interface takes a boolean "activated" parameter and a "users" hash
with mandatory and optional keys as shown.
{
"activated": { "type": "boolean" },
"users":
{
# "stringmap" has only string keys
"type": "stringmap",
"keys":
{
"gecos" : "string",
"uid" : "integer",
"home" : "string",
"shell" : "string"
},
"optional_keys":
{
"passwdhash" : "string",
"groupname" : "string",
"_allow_dup_gid" : "boolean",
"_enforce" : "boolean",
"_nocreate_home" : "boolean",
"_noseed" : "boolean"
}
}
}
I am not attached to the JSON-based DSL, it's just my first prototype.
Parsing and validating the DSL strikes me as boring and surely something
that has been done before, but I'm not crazy about using existing IDLs
like Protocol Buffers, Thrift IDL, WSDL, or the Avro IDL
(http://avro.apache.org/docs/current/idl.html) because they are all too
complex. SWIG is too C-oriented, and so on.
I'd rather have something very simple and easy to parse, which only
supports the basic pure data types in Perl (strings, integers, floating
point, booleans) and lists and hashes that use those data types. I
don't want custom data types. Does such a beast exist in CPAN or
Perl-land? Ideally I should be able to pass it an interface definition
and the actual data, and it should tell me if there's a problem and
where.
Thanks
Ted
language (a sort of DSL). Yes, this is a lot like an IDL. For instance
this interface takes a boolean "activated" parameter and a "users" hash
with mandatory and optional keys as shown.
{
"activated": { "type": "boolean" },
"users":
{
# "stringmap" has only string keys
"type": "stringmap",
"keys":
{
"gecos" : "string",
"uid" : "integer",
"home" : "string",
"shell" : "string"
},
"optional_keys":
{
"passwdhash" : "string",
"groupname" : "string",
"_allow_dup_gid" : "boolean",
"_enforce" : "boolean",
"_nocreate_home" : "boolean",
"_noseed" : "boolean"
}
}
}
I am not attached to the JSON-based DSL, it's just my first prototype.
Parsing and validating the DSL strikes me as boring and surely something
that has been done before, but I'm not crazy about using existing IDLs
like Protocol Buffers, Thrift IDL, WSDL, or the Avro IDL
(http://avro.apache.org/docs/current/idl.html) because they are all too
complex. SWIG is too C-oriented, and so on.
I'd rather have something very simple and easy to parse, which only
supports the basic pure data types in Perl (strings, integers, floating
point, booleans) and lists and hashes that use those data types. I
don't want custom data types. Does such a beast exist in CPAN or
Perl-land? Ideally I should be able to pass it an interface definition
and the actual data, and it should tell me if there's a problem and
where.
Thanks
Ted