Forum Discussion

santosh_csc's avatar
8 years ago

Read a json file from asset in component

How to read content of json file uploaded as asset.

 

${asset.get("/html/assets/test.json")} is returning back the absolute URL.

  • DougS's avatar
    DougS
    Khoros Oracle

    asset.get returns you the fully-qualified URL (the documentation is a bit confusing b/c it says it "returns an asset" when in fact it returns you the URL to that asset), which would be the CDN URL if your community is configured to use a CDN -- it's primary purpose is to make sure that your URLs are returning fully-qualified and that the correct CDN URL is being used.

     

    You will need to use javascript that runs in the browser if you would like to read the contents of that JSON file. You could also use a Studio Endpoint to return JSON if needed.

     

    -Doug