3

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

3
  • Have you tried {{ item["[Measures].[Item0]"] }}? Commented Sep 2, 2014 at 10:17
  • @bmleite yeah thanx it worked, you can post it as answer might help some other too. Commented Sep 2, 2014 at 10:27
  • 2
    Just accept @EdHinchliffe answer, it's more complete than mine :) Commented Sep 2, 2014 at 10:31

1 Answer 1

4

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.

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.