read a local json file in javascript RRS feed

  • Question

  • Hello! I have a navigation app and I want to read a json file and to put it on one of the pages out. Here is my code:

    (function () {
        "use strict";
        WinJS.UI.Pages.define("/pages/someFolder/somePage.html", {
            ready: function (element, options) {
            readJson: function() {
                var packageFolder = Windows.ApplicationModel.Package.current.installedLocation;
                packageFolder.createFolderAsync("folderWithJson", Windows.Storage.CreationCollisionOption.openIfExists).then(
                    function (appDataFolder) {
                        appDataFolder.createFileAsync("myJson.json", Windows.Storage.CreationCollisionOption.openIfExists).then(
                            function (file) {
                                    function (contents) {
                                        var myJson = JSON.parse(contents);
                                        document.getElementById("someElement").innerHTML = myJson;
                                    function (error) {
                            function (error) {
                    function (error) {
            unload: function () {...

    What am I doing wrong? I don't even get a console output.

    Best regards!

    Thursday, July 4, 2013 10:12 AM


All replies

  • Hello,

    To see the JavaScript console, you should select DEBUG > Windows > JavaScript Console in the Visual Studio menus.

    At first, I would like to suggest you make breakpoint to debug your code, so that you can check which line breaks.

    also, please make sure your json file has placed in the correspondingpath and the folderWithJson folder exist.

    details about Windows.ApplicationModel.Package.current.installedLocation you can refer


    Hope this helps, thanks.

    Yanping Wang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 5, 2013 8:41 AM
  • Hello and thank you for your reply!

    I can see my javascript-console, but it doesn't show any errors or the output I want it to show...

    I will now make some breakpoints and debug it...

    Saturday, July 6, 2013 8:20 AM