And if I use "JSON.parse()" call to parse the first element of my 'posts'
object, I received the correct result without error.
console.log('JSON parser: ', JSON.parse(posts[0]));
*OUTPUT*
JSON parser: { Name: 'aaa',
Address: 'bbb',
Phone: '1111''}
This is why I suspected the problem exist inside the <iron-list> call when
iterate thru array of string objects.
BR/Roger
[email protected]於 2016年12月14日星期三 UTC+8上午11時18分57秒寫道:
>
> Hi Daniel,
>
> Thank you for pointing out the original problem. However, now I can be
> sure that my data type is an array. The typeof posts showing on console
> display as following:
>
> object [ '{"Name":"aaa","Address":"bbb","Phone":"1111"}',
> '{"Name":"ccc","Address":"ddd","Phone":"2222"}',
> '{"Name":"eee","Address":"fff","Phone":"3333"}' ]
>
> This array object still fails when passing into <iron-list> tag. Looking
> at the error handling below where it fails, it has something to do with the
> JSON parser not getting the correct data format assuming 'value' is passed
> with my 'posts' array. But as you can see and confirm above, the 'posts'
> data element format should meet the JSON parse standard unless there is
> something else i overlooked. Thanks.
>
> case Array:
> try {
> value = JSON.parse(value);
> } catch (x) {
> value = null;
> console.warn('Polymer::Attributes: couldn`t decode Array as JSON');
> }
> break;
>
> BR/Roger
>
> Daniel Llewellyn於 2016年12月13日星期二 UTC+8下午10時00分11秒寫道:
>>
>>
>>
>> On Tue, 13 Dec 2016 at 03:49 <[email protected]> wrote:
>>
>>> Hi Daniel,
>>>
>>> And the console log will show my posts data as a type string
>>> representation of my array strings. Thanks.
>>>
>>> string [{"Name":"aaa","Address":"bbb","Phone":"1111"},
>>> {"Name":"ccc","Address":"ddd","Phone":"2222"},
>>> {"Name":"eee","Address":"fff","Phone":"3333"}]
>>>
>>
>> OK, that's your problem. `<iron-list>` takes an array, in the `items`
>> property, not a string. You need to change your `posts` variable to contain
>> an array, or use a different variable which does contain an array.
>>
>
Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/polymer-dev/5bc0efc1-2e49-49e0-b778-9f079f83c7e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.