looking for some kind of IDL for Perl types only

Discussion in 'Perl Misc' started by Ted Zlatanov, Apr 11, 2012.

  1. Ted Zlatanov

    Ted Zlatanov Guest

    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
    Ted Zlatanov, Apr 11, 2012
    #1
    1. Advertising

  2. * Ted Zlatanov wrote in comp.lang.perl.misc:
    >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.


    You might be looking for <http://en.wikipedia.org/wiki/JSON#Schema>.

    >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.


    (I do not know how mature the JSON Schema implementations in Perl are.)
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
    25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Bjoern Hoehrmann, Apr 11, 2012
    #2
    1. Advertising

  3. Ted Zlatanov

    Ted Zlatanov Guest

    On Wed, 11 Apr 2012 22:51:40 +0200 Bjoern Hoehrmann <> wrote:

    BH> * Ted Zlatanov wrote in comp.lang.perl.misc:
    >> 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.


    BH> You might be looking for <http://en.wikipedia.org/wiki/JSON#Schema>.

    Ah, very nice. A little bit overkill for my needs, but it's not verbose
    and does not need special compilers.
    http://davidwalsh.name/json-validation has a nice summary.

    BH> (I do not know how mature the JSON Schema implementations in Perl are.)

    JSON::Schema on CPAN is fairly new but it's a start.

    Thank you very much!
    Ted
    Ted Zlatanov, Apr 11, 2012
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pushya

    Java and Rsi IDL

    Pushya, Jun 14, 2004, in forum: Java
    Replies:
    1
    Views:
    526
    Nigel Wade
    Jun 15, 2004
  2. Ken

    ADA/C++/IDL to XML?

    Ken, Sep 5, 2003, in forum: XML
    Replies:
    0
    Views:
    642
  3. Generic Usenet Account

    IDL Vs WSDL ---- a comparison

    Generic Usenet Account, May 27, 2004, in forum: XML
    Replies:
    24
    Views:
    2,458
    Brian Kelly
    Jun 13, 2004
  4. Mike Pennington

    Looking for IDL generator.

    Mike Pennington, Oct 14, 2004, in forum: C++
    Replies:
    1
    Views:
    439
    grahamo
    Oct 14, 2004
  5. James Everton

    Using IDL from a perl script

    James Everton, Oct 19, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    123
    James Everton
    Oct 22, 2007
Loading...

Share This Page