🌐
Mark Nottingham
mnot.net › blog › 2011 › 11 › 25 › linking_in_json
Linking in JSON
November 25, 2011 - I’d like to chime in along with all the others suggesting that their own approach to JSON linking is the best! My approach is a part of the Object Network. Basically, because the Object Network is based on common, shared, stable types or formats, you simply know that something is a link, just by looking at its tag. Here’s a simple example, of a calendar event object that links to a contact object for its location, and user objects for its attendees: { “is”: [ “event” ], “title”: “Over the Air 2011”, “content”: “Top Mobile Meetup at Bletchley Park”, “start”: “Fri, 30 Sep 2011 09:00:00 GMT”, “end”: “Sat, 1 Oct 2011 23:00:00 GMT”, “location”: “http://mansions.com/on/uid-594342-34234.json”, “attendees”: [ “http://nicefolk.com/on/uid-06-7d5d.json”, ..
🌐
JSON
json.org › example.html
JSON Example
<!DOCTYPE glossary PUBLIC "-//OASIS//DTD DocBook V3.1//EN"> <glossary><title>example glossary</title> <GlossDiv><title>S</title> <GlossList> <GlossEntry ID="SGML" SortAs="SGML"> <GlossTerm>Standard Generalized Markup Language</GlossTerm> <Acronym>SGML</Acronym> <Abbrev>ISO 8879:1986</Abbrev> <GlossDef> <para>A meta-markup language, used to create markup languages such as DocBook.</para> <GlossSeeAlso OtherTerm="GML"> <GlossSeeAlso OtherTerm="XML"> </GlossDef> <GlossSee OtherTerm="markup"> </GlossEntry> </GlossList> </GlossDiv> </glossary>
🌐
CRAN
cran.r-project.org › web › packages › jsonlite › vignettes › json-apis.html
Fetching JSON data from REST APIs - CRAN
#search for best sellers books_key <- "&api-key=76363c9e70bc401bac1e6ad88b13bd1d" url <- "http://api.nytimes.com/svc/books/v2/lists/overview.json?published_date=2013-01-01" req <- fromJSON(paste0(url, books_key)) bestsellers <- req$results$list category1 <- bestsellers[[1, "books"]] subset(category1, select = c("author", "title", "publisher"))
🌐
JSONLint
jsonlint.com
JSONLint - The JSON Validator
You can use a URL and JSONLint will scrape it for JSON and parse it. Just structure the link like this, for example: https://jsonlint.com/?url=https://jsonlint.com/datasets/programming-languages.json · You can provide JSON to lint in the URL if you link to JSONLint with the 'json' parameter.
🌐
Restfuljson
restfuljson.org
RESTful JSON · Because adding links in JSON should be easy
A profile link conforming to RFC 6906, as indicated with either a property name of profile_url or profileUrl, MAY be used to link to additional documentation about the resource. The media type application/vnd.restful+json has been registered for this design pattern.
🌐
ReqBin
reqbin.com › req › 5nqtoxbx › get-json-example
How to get JSON from URL?
JSON.stringify() - converts a JavaScript object to a JSON string. An example of an HTTP GET request to fetch JSON data from a ReqBin echo URL.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › JSON
Working with JSON - Learn web development | MDN
Note: Now you've read through this section, you might also want to supplement your learning with Scrimba's JSON review MDN learning partner interactive tutorial, which provides some useful guidance around basic JSON syntax and how to view JSON request data inside your browser's devtools. So, let's work through an example to show how we could make use of some JSON formatted data on a website.
🌐
Medium
hardiquedasore.medium.com › how-to-add-a-link-to-json-162fc4b6c732
How to add a link to JSON?. In another edition to the JSON series… | by Hardique Dasore | Medium
June 8, 2023 - In another edition to the JSON series, we can also add clickable links are part of the paragraph in the JSON. We can encapsulate the link in the anchor tag <a href='#'></a>. We can add the redirection link in the href so that the user can redirect ...
🌐
Json-ld
json-ld.org
JSON-LD - JSON for Linked Data
It allows an application to start at one piece of Linked Data, and follow embedded links to other pieces of Linked Data that are hosted on different sites across the Web. ... { "@context": "https://json-ld.org/contexts/person.jsonld", "@id": "http://dbpedia.org/resource/John_Lennon", "name": "John Lennon", "born": "1940-10-09", "spouse": [ "http://dbpedia.org/resource/Yoko_Ono", "http://dbpedia.org/resource/Cynthia_Lennon" ] }
Find elsewhere
🌐
DEV Community
dev.to › hardiquedasore › how-to-add-link-to-json-49a3
How to a add link to JSON? - DEV Community
June 8, 2023 - In another edition to the JSON series, we can also add clickable links are part of the paragraph in the JSON. We can encapsulate the link in the anchor tag <a href='#'></a>. We can add the redirection link in the href so that the user can redirect ...
🌐
Evertpot
evertpot.com › json-links
Reinventing the wheel when encoding links in JSON
The json-home format has 2 places where link relationships are used, so I encoded an example for each.
Top answer
1 of 2
1

Add a <a> tag with href and target="_black" for opening the link in new tab and use split to remove the href from json.

<html xmlns="http://www.w3.org/1999/xhtml">
<head> 
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>   
    <table id="userdata" border="5">            
            <th>Revision  Date</th>
            <th>Document  Name</th>
            <th>Department </th>
            <th>Description</th>
            <th>Link</th>     
    </table>
<script>
        var data = {
        "person": [{
            "revisiondate": "21 April 2016",
            "documentname": "1658MC",
            "department": "Sales",
            "description": "Available",
            "link": "href=1658MC.pdf"
        }, {
            "revisiondate": "16 April 2016",
            "documentname": "VCX16B",
            "department": "Enginnering",
            "description": "Not Available",
            "link": "href=VCX16B.pdf"
        }, {
            "revisiondate": "15 March 2016",
            "documentname": "AB36F",
            "department": "Custumer Services",
            "description":  "Not Available",
            "link": "href=AB36F.pdf"
        }, {
            "revisiondate": "12 Agust 2016",
            "documentname": "FC25D",
            "department": "Technical Support",
            "description": "Not Available",
            "link": "href=FC25D.pdf"
        }]
    } 
    //$.getJSON("new4.json", function(data) {
    // console.log(data);

    //$.getJSON('new4.json', function(data) {
        $.each(data.person, function(i, person) {
            var tblRow =    "<tr><td>" + person.revisiondate + 
                            "</td><td>" + person.documentname + 
                            "</td><td>" + person.department +
                            "</td><td>" + person.description + 
                            "</td><td><a target='_blank' href='"+ person.link.split('href=')[1]+"' >"+person.link.split('href=')[1]+"</a></td></tr>"
            $(tblRow).appendTo("#userdata tbody");
        });
        //});
</script>
</body>
</html>

2 of 2
0
$.each(data.person, function(i, person) {
            var tblRow =    "<tr><td>" + person.revisiondate + 
                            "</td><td>" + person.documentname + 
                            "</td><td>" + person.department +
                            "</td><td>" + person.description + 
                            "</td><a href='" + person.link + "'>link text</a><td>" +
                            "</td></tr>"
            $(tblRow).appendTo("#userdata tbody");
        });

You should remove the attrribute 'href' from your json

Or you could just add single quotes to your json data links like so

var data = {
        "person": [{
            "revisiondate": "21 April 2016",
            "documentname": "1658MC",
            "department": "Sales",
            "description": "Available",
            "link": "href='1658MC.pdf'"
        }, {
            "revisiondate": "16 April 2016",
            "documentname": "VCX16B",
            "department": "Enginnering",
            "description": "Not Available",
            "link": "href='VCX16B.pdf'"
        }, {
            "revisiondate": "15 March 2016",
            "documentname": "AB36F",
            "department": "Custumer Services",
            "description":  "Not Available",
            "link": "href='AB36F.pdf'"
        }, {
            "revisiondate": "12 Agust 2016",
            "documentname": "FC25D",
            "department": "Technical Support",
            "description": "Not Available",
            "link": "href='FC25D.pdf'"
        }]


$.each(data.person, function(i, person) {
            var tblRow =    "<tr><td>" + person.revisiondate + 
                            "</td><td>" + person.documentname + 
                            "</td><td>" + person.department +
                            "</td><td>" + person.description + 
                            "</td><a " + person.link + ">link text</a><td>" +
                            "</td></tr>"
            $(tblRow).appendTo("#userdata tbody");
        });
🌐
JSON:API
jsonapi.org › format
JSON:API — Latest Specification (v1.1)
For example, a GET request to an individual article could return: HTTP/1.1 200 OK Content-Type: application/vnd.api+json { "links": { "self": "http://example.com/articles/1" }, "data": { "type": "articles", "id": "1", "attributes": { "title": "JSON:API paints my bikeshed!"
🌐
W3Schools
w3schools.com › js › js_json.asp
JavaScript JSON
JSON Intro JSON Syntax JSON vs XML JSON Data Types JSON Parse JSON Stringify JSON Objects JSON Arrays JSON Server JSON PHP JSON HTML JSON JSONP JS jQuery · jQuery Selectors jQuery HTML jQuery CSS jQuery DOM JS Graphics · JS Graphics JS Canvas JS Plotly JS Chart.js JS Google Chart JS D3.js JS Examples
🌐
GitHub
gist.github.com › berb › 1133601
JSON Example with Link Relations · GitHub
JSON Example with Link Relations. GitHub Gist: instantly share code, notes, and snippets.
🌐
Adobe
opensource.adobe.com › Spry › samples › data_region › JSONDataSetSample.html
JSON Data Set Sample
The JSON output from different Server APIs can range from simple to highly nested and complex. The examples on this page attempt to illustrate how the JSON Data Set treats specific formats, and gives examples of the different constructor options that allow the user to tweak its behavior.
🌐
JSONPlaceholder
jsonplaceholder.typicode.com
JSONPlaceholder - Free Fake REST API
JSONPlaceholder is a free online REST API that you can use whenever you need some fake data. It can be in a README on GitHub, for a demo on CodeSandbox, in code examples on Stack Overflow, ...or simply to test things locally.
🌐
jsonurl
jsonurl.org
JSON inside a URL
JSON->URL defines a text format for the JSON data model suitable for use within a URL or URI.