0

A webservice is returining jsonString. After parsing, i'll have to bind it's value inside table.

the easiest way to do is by finding each object inside the string. For eg: my string is returned in the format:

{
  "Table1": [
    {
      "ProjectId": "VS200-001---",
      "day1": "---",
      "day2": "---",
      "day3": "---",
      "day4": "---",
      "day5": "---",
      "day6": "---",
      "day7": "---",
      "day8": "---",
      "day9": "---",
      "day10": "---",
      "day11": "---",
      "day12": "---",
      "day13": "4.3",
      "day14": "2",
      "day15": "---",
      "day16": "---",
      "day17": "---",
      "day18": "---",
      "day19": "---",
      "day20": "---",
      "day21": "---",
      "day22": "---",
      "day23": "5",
      "day24": "---",
      "day25": "---",
      "day26": "---",
      "day27": "---",
      "day28": "---",
      "day29": "---",
      "day30": "---"
    },....      
  ]
} 

after parsing i got the object's.

for(var x=0; x< _data.Length;x++)
{
  for(var dys = 0; dys< dates.Length;dys++){
  var val = "day" + (dys+1);
  tbody += _data[0] .val + "</tr>"; 
///Here exception is generating incorrect format
//but if i use here _data[0].day1 it will show the value for day1
//how to convert string to object inorder to retrieve the value

}
}
0

1 Answer 1

1

When accessing an object using the key stored in a variable you need to use array notation. Change this:

_data[0].val

To this:

_data[0][val]

From the looks of your code you also need to close the td as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.