Loading ...
Sorry, an error occurred while loading the content.

31Re: [json] backslash double-quote

Expand Messages
  • Jon Schull
    Aug 1, 2005
      Thanks for the speedy and extensive reply

      Yes, my closing ")" was an error

      I'm something of an E-gnoramus, so I will ask before attempting to
      understand your detailed reply, are there E-parsers available for
      python and javascript?


      =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
      Jon Schull, Ph.D.
      Associate Professor
      Information Technology
      Rochester Institute of Technology
      102 Lomb Memorial Drive
      Rochester, New York 14623
      schull@... 585-738-6696

      On Aug 1, 2005, at 5:04 PM, Mark Miller wrote:

      > jonschull5 wrote:
      > > Hi,
      > >
      > > Shouldn't it be possible to jsonize a string like this?
      > >
      > > {"doubleQuoteSurroundedBySpaces":" \" "}}'
      >
      >
      > Assuming your closing ")'" is an error, E's embedded term-tree
      > language
      > (<http://www.erights.org/data/terml/index.html>) accepts this just
      > fine:
      >
      > ? term`{"doubleQuoteSurroundedBySpaces":" \" "}`
      > # value: term`{"doubleQuoteSurroundedBySpaces": " \" "}`
      >
      > We altered E's term-tree language to be a superset of JSON. Shown
      > above is a
      > command-line interaction with the E interpreter. "? " is E's
      > prompt. ("> " is
      > E's continuation prompt, and is not shown here.) The text to the
      > right of the
      > "? " is an E expression entered by the user. The expression shown
      > above is a
      > quasi-literal expression, consisting of the name of the quasi-
      > parser to the
      > left of the back-tick, and the quasi-literal string to be parsed
      > within the
      > back-ticks. In this case we're just using it as a parser. To better
      > see what's
      > going on, below we invoke E's term-tree parser explicitly on your
      > JSON string:
      >
      > ? def str := `{"doubleQuoteSurroundedBySpaces":" \" "}`
      > # value: "{\"doubleQuoteSurroundedBySpaces\":\" \\\" \"}"
      >
      > ? def termParser := <import:org.quasiliteral.term.TermParser>
      > # value: <makeTermParser>
      >
      > ? def tt := termParser(str)
      > # value: term`{"doubleQuoteSurroundedBySpaces": " \" "}`
      >
      > We can use a quasi-literal pattern to pattern match this tree and
      > extract its
      > components. The text between the "@{" and "}" is a pattern in the E
      > programming language. Whatever the term-tree quasi-literal pattern
      > extracts at
      > that position is matched against this E pattern, which in this case
      > just
      > coerces and binds variables k and v.
      >
      > Since both E and the term-tree language use ":", but for two quite
      > different
      > purposes, our convention is to put a space to the left of an E ":"
      > but a space
      > to the right of a term-tree colon.
      >
      > ? def term`{@{k :String}: @{v :String}}` := tt
      > # value: term`{"doubleQuoteSurroundedBySpaces": " \" "}`
      >
      > ? k
      > # value: "doubleQuoteSurroundedBySpaces"
      >
      > ? v
      > # value: " \" "
      >
      > For more, see <http://www.erights.org/elang/quasi/terms/like-
      > ellipses.html>
      > and the section "Quasi-JSON back from the dead" at
      > <http://www.eros-os.org/pipermail/e-lang/2005-May/010646.html>.
      >
      > --
      > Text by me above is hereby placed in the public domain
      >
      > Cheers,
      > --MarkM
      >
      >
      > YAHOO! GROUPS LINKS
      >
      > Visit your group "json" on the web.
      >
      > To unsubscribe from this group, send an email to:
      > json-unsubscribe@yahoogroups.com
      >
      > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
      >
      >



      [Non-text portions of this message have been removed]
    • Show all 13 messages in this topic