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

eval() throwing error in IE

Expand Messages
  • mahesh_mission
    Hi, I have a JSON object which has a strcture like this : { MainData : { Company : { Name : ABC Ltd , Address : }, Data : { 001 : { Name :
    Message 1 of 3 , Sep 26, 2007
    View Source
    • 0 Attachment
      Hi,

      I have a JSON object which has a strcture like this :

      { "MainData":
      {

      "Company":
      {
      "Name":"ABC Ltd",
      "Address":"<address>"
      },
      "Data":
      {
      "001":
      {
      "Name": "Test",
      "Age":"45"
      },
      "002":
      {
      "Name" : "Sample",
      "Age":"35"
      }
      }
      }
      }

      In this, "001", "002" are emloyee numbers.
      Now assume the employee number is passed from an another function as
      an input. (Let it be EmpNo)

      Now, I need to check if the passed in employee number is present in
      the JSON structure and accordingly retreive the data.

      I need to use the javascript for this.
      If I try to say

      MainData.Company.Data.eval(EmpNo);

      This works fine in mozilla.

      But if I run the same program in IE, I get an error message "object
      doesn't support this property or method".

      I found that the eval() in this case doesn't work in IE. Could you
      please suggest a solution.

      Thanks a lot.
    • Douglas Crockford
      ... That form of eval is not in the ECMAScript standard. I recommend that you stick with the standard language.
      Message 2 of 3 , Sep 27, 2007
      View Source
      • 0 Attachment
        --- In json@yahoogroups.com, "mahesh_mission" <mahesh_mission@...> wrote:

        > If I try to say
        >
        > MainData.Company.Data.eval(EmpNo);
        >
        > This works fine in mozilla.
        >
        > But if I run the same program in IE, I get an error message "object
        > doesn't support this property or method".

        That form of eval is not in the ECMAScript standard. I recommend that
        you stick with the standard language.
      • kriszyp
        I think you want: MainData.Company.Data[EmpNo]
        Message 3 of 3 , Sep 27, 2007
        View Source
        • 0 Attachment
          I think you want:
          MainData.Company.Data[EmpNo]
        Your message has been successfully submitted and would be delivered to recipients shortly.