Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4616018
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:55:21+00:00 2026-05-22T01:55:21+00:00

How do I add an attribute rel=blah to a JSON string? I have the

  • 0

How do I add an attribute rel=blah to a JSON string? I have the following in a JSON file:

[
    {"image":"/images/image1.png", "link":"http://mylink.com"},
    {"image":"/images/image2.png", "link":"http://mylink.com"},
    {"image":"/images/image3.png", "link":"http://mylink.com"}
]

The output creates the images and links I want on the page. But I’ve tried to add a rel attribute like following:

{"image":"/images/image3.png", "link":{"rel":"blah","href":"http://mylink.com"}}
{"image":"/images/image3.png", "link":{"rel":"blah","uri":"http://mylink.com"}}

but the output was always the same: <a href="object Object"> Seems like a simple thing but I can’t seem to find the right syntax anywhere.

The piece of the image scrubber javascript that produces the image/link is this:

 setImage: function(index) {
        this.element.empty();
        var anchor = new Element('a', {
            'href': this.imageList[index].link
        });
        this.images[index].inject(anchor);
        anchor.inject(this.element);
        this.oldIndex = index;
    },
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:55:22+00:00Added an answer on May 22, 2026 at 1:55 am

    This is a question about Javascript, not JSON. You have to rewrite the function, which generates the HTML output, for your new object structure. Now I don’t know what you’re working with there, but from the function you posted, this is my guess what you have to change:

    setImage: function(index) {
        this.element.empty();
        var anchor = new Element('a', {
    
             // here it comes:
             'href': this.imageList[index].link.href,
             'rel': this.imageList[index].link.rel
             // that's it
    
        });
        this.images[index].inject(anchor);
        anchor.inject(this.element);
        this.oldIndex = index;
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question 1) I have a control to which I add an attribute from the
I have an element where I'm already using the rel attribute, but I would
I'm trying to add a rel=lightframe attribute to all my 'edit' links within my
I have the following HtmlLink: HtmlLink htmlLink = new HtmlLink(); htmlLink.Attributes.Add(href, /style/ + category
How do I add the attribute selected to a drop down menu option based
can I add BehaviorID attribute for asp.net textbox and use it to be recognize
I can use TypeDescriptor.AddAttributes to add an attribute to a type in runtime. How
In my E-commerce application, I want to add a attribute to a Product, only
If I add the [SuppressUnmanagedCodeSecurity()] attribute to a class, is it equivalent to adding
I'm trying to add the jVal attribute to a textbox that I created in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.