If you are regularly working with JSON, have you considered using JSON?

I realize there are times when one just wants something quick and dirty and throwaway. However, if this is more than a one-off throw-away need, devoting time to developing a collection of regexes to work with a well established streaming format seems to me a bit foolish. The code one writes will not have anywhere near the degree of long term reusability and reliability that a proper parsing module will.

For example, can you be sure that your arrays will always have only scalar elements? What about arrays nested in arrays? Arrays of hashes? That isn't even a question you need to worry about if you use a module that knows how to parse JSON in full.


In reply to Re: Replacement of Bracketed Expressions for JSON output by ELISHEVA
in thread Replacement of Bracketed Expressions for JSON output by Ardii

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.