0

I have JSON in Javascript like this:

var json = {
    "total": "100",
    "page":"1",
    "records":"100",
    "rows": [
        {
            "no": "1",
            "part_number": "2",
            "part_name": "3",
            "price": "4",
            "note": "8"
        }
    ]
};

and I want to add

"test1":"5",
"test2":"7"

into JSON above.

so it will be like this:

var json = {
    "total":"100",
    "page":"1",
    "records":"100",
    "rows": [
        {
            "no": "1",
            "part_number": "2",
            "part_name": "3",
            "price": "4",
            "test1": "5",
            "test2": "7",
            "note":"8"
        }
    ]
};
1

2 Answers 2

2
json["rows"][0]["test1"] = "5";
json["rows"][0]["test2"] = "7";
Sign up to request clarification or add additional context in comments.

Comments

2

Just:

json.rows[0].test1=5; // or if you want "5"
json.rows[0].test2=7;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.