Page 1 of 1

JSON formatting issue

Posted: Mon Nov 12, 2018 8:05 pm
by awasu.user
After few long months I lost my data and I start coding Awasu plugins from scratch. I was shock that previous template is not working:

Code: Select all

{
{%REPEAT% Channels-IfGroupingItems insert=","}
"{%CHANNEL-METADATA% name encode=jsonval}": [
    {%REPEAT% FeedItems insert=","} {
        "id": "{%ITEM-METADATA% AwasuId encode=jsonval}",
        "title": "{%ITEM-METADATA% name! encode=jsonval}",
        "published": "{%ITEM-METADATA% timestamp encode=jsonval}",
        "url": "{%ITEM-METADATA% url encode=jsonval}",
        "state": "{%ITEM-STATE% encode=jsonval}"
    } {%/REPEAT%}
]
{%/REPEAT%}
}
I get extra ' " ' in title of channel. I found too internal bug in Awasu when I use search channel. Sometimes it's get XML wrong character format (what it should not happened as is internal behaviour. Now only solution is make pseudo code mixing JSON and CSV what is wrong idea. So then how get all specified in report channel as JSON?

Questions
1. How get correct JSON data?
2. Why API has not in channel operation API call for channel/feeds/get or something like that? (A lot of data is in JSON so why not add simple return articles data with API call for specified channels?)

Re: JSON formatting issue

Posted: Tue Nov 13, 2018 5:11 am
by support
awasu.user wrote:
Mon Nov 12, 2018 8:05 pm
I get extra ' " ' in title of channel.
You've wrapped the JSON values in double quotes i.e. it should be:

Code: Select all

"id": {%ITEM-METADATA% AwasuId encode=jsonval},
The different between encode=json and encode=jsonval is that the latter will wrap values in double quotes if necessary i.e. numeric values will stay numeric.
awasu.user wrote:
Mon Nov 12, 2018 8:05 pm
I found too internal bug in Awasu when I use search channel. Sometimes it's get XML wrong character format
Send me what you can so that I can reproduce the problem. This can happen sometimes when the feed publisher makes a misteak in the encoding themself, and the problem then propagates throughout Awasu.
awasu.user wrote:
Mon Nov 12, 2018 8:05 pm
Why API has not in channel operation API call for channel/feeds/get or something like that?
You can extract feed items from Awasu using $/feedItems/get, or via a report (e.g. look at MetaChannels.template for an example). Once content is in Awasu, there really isn't a concept of a "feed" any more, there's just a (possibly infinite) stream of items.