Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I want to access data with key name as [Measure].[item0] as the key names and when i access this in my html it gives error like json is ine format "[Measure].[item0]":"45" my code for accessing this is

<div ng-repeat="item in allItems ">
      <div >{{item.([Measures].[Item0])}}</div>
</div>

I have tried this using braces and paranthesis also byenclosing it in () and [] i just want to know that how to access the key name with full stop

share|improve this question
    
Have you tried {{ item["[Measures].[Item0]"] }}? –  bmleite Sep 2 '14 at 10:17
    
@bmleite yeah thanx it worked, you can post it as answer might help some other too. –  user3631413 Sep 2 '14 at 10:27
1  
Just accept @EdHinchliffe answer, it's more complete than mine :) –  bmleite Sep 2 '14 at 10:31

1 Answer 1

up vote 3 down vote accepted

It's not particularly clear what you are trying to do from the question, but if you have an object like this:

{
  item: {
    "[Measures].[Item0]": "some data",
    someProperty        : 31231
  }
}

Then to output "some data" the expression would be like this:

{{item["[Measures].[Item0]"]}}

If your item looks like this:

{
  item: {
    Measures: {
      Item0: "some data",
      Item1: "some other data"
    },
    someProperty        : 31231
  }
}

Then your html for "some data" should be

{{item.Measures.Item0}}

In other words:

{{ item.key === item["key"] }}

The square bracket notation can contain restricted/special characters, whilst the dot notation cannot. To be quite honest, you should fix the data source if it looks like the first, it's really not good practise.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.