Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Amir Khan 1287 posts 2744 karma points
    Jan 30, 2014 @ 16:41
    Amir Khan
    0

    Output JSON from node properties

    How could I output JSON from node properties? I have the following, but it seems to just wrap the value in quotes, I'm not really sure how to manipulate the string into the proper format (below)

    Current: @Html.Raw(Json.Encode(@page.uBlogsyPostDate.ToString("yyyy-mm-dd HH:mm"))) which outputs: "2014-35-23 14:35"

    Correct format:

    [
    {
    "date": "2014-01-30 17:30:00",
    "type": "meeting",
    "title": "Event 1",
    "description": "Lorem Ipsum dolor set",
    "url": "/"
    }
    ]
  • Amir Khan 1287 posts 2744 karma points
    Jan 30, 2014 @ 17:05
    Amir Khan
    1

    Incase anyone needs this, here's how you can do it.

     

    var news = new {
    date = @page.uBlogsyPostDate.ToString("yyyy-MM-dd HH:mm"),
    type = @page.Name,
    title = @page.Name,
    description = @page.uBlogsyContentSummary,
    url = @page.Url
    };

    @Html.Raw(Json.Encode(news))
Please Sign in or register to post replies

Write your reply to:

Draft