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

Re: Newbie question re: converting regexp.exec(str) result to JSON

Expand Messages
  • Douglas Crockford
    ... myObject = {index: myArray.index, input: myArray.input, array: myArray}; jsontext = JSON.stringify(myObject);
    Message 1 of 2 , Nov 6, 2007
    View Source
    • 0 Attachment
      --- In json@yahoogroups.com, "Jim Fricker" <yahoo@...> wrote:
      >
      > What would be the recommended way of converting the result of an
      > regexp.exec(str) method call to JSON? The result is an array but with
      > two extra properties; index and input.
      >
      > If I use stringify then I just get the array elements and the index
      > and input properties are missing. Is there a way of tricking the
      > stringify function into treating this as an object rather than an
      > array so I can get all the elements/properties/values?


      myObject = {index: myArray.index, input: myArray.input, array: myArray};
      jsontext = JSON.stringify(myObject);
    Your message has been successfully submitted and would be delivered to recipients shortly.