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

  • Home
  • SEARCH
  • 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 8503529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:46:49+00:00 2026-06-11T01:46:49+00:00

I am working on a network graph code that is rendered as json array.

  • 0

I am working on a network graph code that is rendered as json array.
I need to change to code in order to give the array data received from another file.
The code that I have:

var json = [
{
    "adjacencies": 
    [
        {
            "nodeTo": "A",
            "nodeFrom": "B",
             "data": 
             {
                 "$color": "#557EAA"
             }
        }
    ],

    "data": 
    {
        "$color": "#909291",
        "$type": "circle",
        "$dim": 20
    },

    "id": "B",
    "name": "B"

},
{
    "adjacencies": 
    [
        {
          "nodeTo": "C",
          "nodeFrom": "D",
          "data": 
          {
             "$color": "#416D9C"
          }
        }
    ],
    "data": 
    {
       "$color": "#83548B",
       "$type": "circle",
       "$dim": 20
    },
    "id": "D",
    "name": "D"
 },
];

I need to create a for loop that goes from 1 to x, and in every iteration, i add a value in the json array. (A value is composed of “adjacencies”, “data”, “id”, “name”)

Note that the nodeTo, nodeFrom, id and name values are stored in another array, so in the loop i can set their values.

Thanks in advance:)

I have tried the .push as follows:
var json = [];
var adjacencies = [];

for (i = 0; i < count; i++) {
    var adjacencies = [];
    var source = impactsString[i].Source;
    var target = impactsString[i].Target;
    var number = impactsString[i].NumberOfImpacts;
    adjacencies.push({ nodeTo: target, nodeFrom: source });
    json.push({ adjacencies: adjacencies, id: source, name: source });
}

But still not working

  • 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-06-11T01:46:51+00:00Added an answer on June 11, 2026 at 1:46 am

    Use Array.push() as follows:

    var json = [
    {
        "adjacencies": 
        [
            {
                "nodeTo": "A",
                "nodeFrom": "B",
                 "data": 
                 {
                     "$color": "#557EAA"
                 }
            }
        ],
    
        "data": 
        {
            "$color": "#909291",
            "$type": "circle",
            "$dim": 20
        },
    
        "id": "B",
        "name": "B"
    
    },
    {
        "adjacencies": 
        [
            {
              "nodeTo": "C",
              "nodeFrom": "D",
              "data": 
              {
                 "$color": "#416D9C"
              }
            }
        ],
        "data": 
        {
           "$color": "#83548B",
           "$type": "circle",
           "$dim": 20
        },
        "id": "D",
        "name": "D"
     },
    ];
    
    var i;
    for (i = 0; i < 500; i += 1) {
        json.push({
             "adjacencies": 
             [
                  {
                        "nodeTo": "A",
                        "nodeFrom": "B",
                         "data": 
                         {
                              "$color": "#557EAA"
                         }
                  }
             ],
    
             "data": 
             {
                  "$color": "#909291",
                  "$type": "circle",
                  "$dim": 20
             },
    
             "id": "B",
             "name": "B"
    
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a community detection algorithm for analyzing social network data from
I'm currently working with a dead network application that received packets for a chat.
I am working on a network programming and I need a data structure to
Hi I'm working on trying to cluster network data from the 1999 darpa data
I'm working on a Rails app that implements some social network features as relationships,
I'm working on a game that uses local area network. Like most of multiplayer
I'm working on a phonegap iPhone app which downloads content from the network in
I'm working on an Android widget that will show the current network state (i.e
I am working on internal PHP application where users login only from our network
I am working on a social network that should allow members to chat with

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.