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

Re: Fwd: [json] Comparing the metadata field with a variable passed

Expand Messages
  • mahesh_mission
    Hi, It works fine now. Thanks a lot for your timely help!! ... function as ... present in
    Message 1 of 2 , Aug 26, 2007
    • 0 Attachment
      Hi,

      It works fine now.
      Thanks a lot for your timely help!!

      --- In json@yahoogroups.com, "Philip Tellis" <philip.tellis@...>
      wrote:
      >
      > On 26/08/07, mahesh_mission <mahesh_mission@...> wrote:
      > >
      > > 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);
      >
      > avoid using eval. Just use the "in" operator"
      >
      > if(EmpNo in MainData.Company.Data)
      >
      > in checks for the existence of a key.
      >
      >
      > --
      > hello world
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.