I want to bring a single value from my json file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
This brings me all the values of the json file
Example: I have id, name and lastname, I want to bring the id value
fs.readFile("user.json", function (err, data) {
if (err) throw err;
console.log(data.toString());
});
info file json
{"Identificador":0,"Nombre_Principal":"man","Nombre_Paterno":"man","Nombre_Materno":"man","Contrasena":"man","Correo":"man@man.com","Posicion":"User","Token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Im1hbiIsIm5iZiI6MTU0MjgzODU5OCwiZXhwIjoxNTQyODQwMzk4LCJpYXQiOjE1NDI4Mzg1OTgsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjUyMjQiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjY1MjI0In0.W9Tck4QjzCoP2g0CdFIsmshSUoZbzi8AmzR9EnRYIVQ","Estatus":0}
javascript node.js json
|
show 4 more comments
This brings me all the values of the json file
Example: I have id, name and lastname, I want to bring the id value
fs.readFile("user.json", function (err, data) {
if (err) throw err;
console.log(data.toString());
});
info file json
{"Identificador":0,"Nombre_Principal":"man","Nombre_Paterno":"man","Nombre_Materno":"man","Contrasena":"man","Correo":"man@man.com","Posicion":"User","Token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Im1hbiIsIm5iZiI6MTU0MjgzODU5OCwiZXhwIjoxNTQyODQwMzk4LCJpYXQiOjE1NDI4Mzg1OTgsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjUyMjQiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjY1MjI0In0.W9Tck4QjzCoP2g0CdFIsmshSUoZbzi8AmzR9EnRYIVQ","Estatus":0}
javascript node.js json
3
Use JSON.parse() then access what you need as you would with any JavaScript object
– charlietfl
Nov 22 '18 at 1:48
I could do visual, please
– Manuel Rodriguez
Nov 22 '18 at 1:56
@Brad What are you talking about? What was given is fine. An actual JSON file is not needed to answer this question.
– Spencer Wieczorek
Nov 22 '18 at 2:03
sorry, I did not notice that I put jquery by mistake
– Manuel Rodriguez
Nov 22 '18 at 2:03
@SpencerWieczorek The whole question is how to access properties of an object. Seeing an actual structure is helpful.
– Brad
Nov 22 '18 at 2:05
|
show 4 more comments
This brings me all the values of the json file
Example: I have id, name and lastname, I want to bring the id value
fs.readFile("user.json", function (err, data) {
if (err) throw err;
console.log(data.toString());
});
info file json
{"Identificador":0,"Nombre_Principal":"man","Nombre_Paterno":"man","Nombre_Materno":"man","Contrasena":"man","Correo":"man@man.com","Posicion":"User","Token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Im1hbiIsIm5iZiI6MTU0MjgzODU5OCwiZXhwIjoxNTQyODQwMzk4LCJpYXQiOjE1NDI4Mzg1OTgsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjUyMjQiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjY1MjI0In0.W9Tck4QjzCoP2g0CdFIsmshSUoZbzi8AmzR9EnRYIVQ","Estatus":0}
javascript node.js json
This brings me all the values of the json file
Example: I have id, name and lastname, I want to bring the id value
fs.readFile("user.json", function (err, data) {
if (err) throw err;
console.log(data.toString());
});
info file json
{"Identificador":0,"Nombre_Principal":"man","Nombre_Paterno":"man","Nombre_Materno":"man","Contrasena":"man","Correo":"man@man.com","Posicion":"User","Token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Im1hbiIsIm5iZiI6MTU0MjgzODU5OCwiZXhwIjoxNTQyODQwMzk4LCJpYXQiOjE1NDI4Mzg1OTgsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjUyMjQiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjY1MjI0In0.W9Tck4QjzCoP2g0CdFIsmshSUoZbzi8AmzR9EnRYIVQ","Estatus":0}
javascript node.js json
javascript node.js json
edited Nov 22 '18 at 2:03
Manuel Rodriguez
asked Nov 22 '18 at 1:42
Manuel RodriguezManuel Rodriguez
83
83
3
Use JSON.parse() then access what you need as you would with any JavaScript object
– charlietfl
Nov 22 '18 at 1:48
I could do visual, please
– Manuel Rodriguez
Nov 22 '18 at 1:56
@Brad What are you talking about? What was given is fine. An actual JSON file is not needed to answer this question.
– Spencer Wieczorek
Nov 22 '18 at 2:03
sorry, I did not notice that I put jquery by mistake
– Manuel Rodriguez
Nov 22 '18 at 2:03
@SpencerWieczorek The whole question is how to access properties of an object. Seeing an actual structure is helpful.
– Brad
Nov 22 '18 at 2:05
|
show 4 more comments
3
Use JSON.parse() then access what you need as you would with any JavaScript object
– charlietfl
Nov 22 '18 at 1:48
I could do visual, please
– Manuel Rodriguez
Nov 22 '18 at 1:56
@Brad What are you talking about? What was given is fine. An actual JSON file is not needed to answer this question.
– Spencer Wieczorek
Nov 22 '18 at 2:03
sorry, I did not notice that I put jquery by mistake
– Manuel Rodriguez
Nov 22 '18 at 2:03
@SpencerWieczorek The whole question is how to access properties of an object. Seeing an actual structure is helpful.
– Brad
Nov 22 '18 at 2:05
3
3
Use JSON.parse() then access what you need as you would with any JavaScript object
– charlietfl
Nov 22 '18 at 1:48
Use JSON.parse() then access what you need as you would with any JavaScript object
– charlietfl
Nov 22 '18 at 1:48
I could do visual, please
– Manuel Rodriguez
Nov 22 '18 at 1:56
I could do visual, please
– Manuel Rodriguez
Nov 22 '18 at 1:56
@Brad What are you talking about? What was given is fine. An actual JSON file is not needed to answer this question.
– Spencer Wieczorek
Nov 22 '18 at 2:03
@Brad What are you talking about? What was given is fine. An actual JSON file is not needed to answer this question.
– Spencer Wieczorek
Nov 22 '18 at 2:03
sorry, I did not notice that I put jquery by mistake
– Manuel Rodriguez
Nov 22 '18 at 2:03
sorry, I did not notice that I put jquery by mistake
– Manuel Rodriguez
Nov 22 '18 at 2:03
@SpencerWieczorek The whole question is how to access properties of an object. Seeing an actual structure is helpful.
– Brad
Nov 22 '18 at 2:05
@SpencerWieczorek The whole question is how to access properties of an object. Seeing an actual structure is helpful.
– Brad
Nov 22 '18 at 2:05
|
show 4 more comments
1 Answer
1
active
oldest
votes
Before you can access the actual data inside the string containing JSON, you have to parse it first. Use JSON.parse()
for this.
fs.readFile('user.json', function (err, data) {
if (err) throw err;
data = JSON.parse(data); // Convert JSON into an actual JavaScript object
console.log(data.Identificador); // Access object properties with the dot `.` notation
});
Thank you for the answer!
– Manuel Rodriguez
Nov 22 '18 at 2:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422781%2fi-want-to-bring-a-single-value-from-my-json-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Before you can access the actual data inside the string containing JSON, you have to parse it first. Use JSON.parse()
for this.
fs.readFile('user.json', function (err, data) {
if (err) throw err;
data = JSON.parse(data); // Convert JSON into an actual JavaScript object
console.log(data.Identificador); // Access object properties with the dot `.` notation
});
Thank you for the answer!
– Manuel Rodriguez
Nov 22 '18 at 2:13
add a comment |
Before you can access the actual data inside the string containing JSON, you have to parse it first. Use JSON.parse()
for this.
fs.readFile('user.json', function (err, data) {
if (err) throw err;
data = JSON.parse(data); // Convert JSON into an actual JavaScript object
console.log(data.Identificador); // Access object properties with the dot `.` notation
});
Thank you for the answer!
– Manuel Rodriguez
Nov 22 '18 at 2:13
add a comment |
Before you can access the actual data inside the string containing JSON, you have to parse it first. Use JSON.parse()
for this.
fs.readFile('user.json', function (err, data) {
if (err) throw err;
data = JSON.parse(data); // Convert JSON into an actual JavaScript object
console.log(data.Identificador); // Access object properties with the dot `.` notation
});
Before you can access the actual data inside the string containing JSON, you have to parse it first. Use JSON.parse()
for this.
fs.readFile('user.json', function (err, data) {
if (err) throw err;
data = JSON.parse(data); // Convert JSON into an actual JavaScript object
console.log(data.Identificador); // Access object properties with the dot `.` notation
});
answered Nov 22 '18 at 2:07
BradBrad
117k29239398
117k29239398
Thank you for the answer!
– Manuel Rodriguez
Nov 22 '18 at 2:13
add a comment |
Thank you for the answer!
– Manuel Rodriguez
Nov 22 '18 at 2:13
Thank you for the answer!
– Manuel Rodriguez
Nov 22 '18 at 2:13
Thank you for the answer!
– Manuel Rodriguez
Nov 22 '18 at 2:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422781%2fi-want-to-bring-a-single-value-from-my-json-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Use JSON.parse() then access what you need as you would with any JavaScript object
– charlietfl
Nov 22 '18 at 1:48
I could do visual, please
– Manuel Rodriguez
Nov 22 '18 at 1:56
@Brad What are you talking about? What was given is fine. An actual JSON file is not needed to answer this question.
– Spencer Wieczorek
Nov 22 '18 at 2:03
sorry, I did not notice that I put jquery by mistake
– Manuel Rodriguez
Nov 22 '18 at 2:03
@SpencerWieczorek The whole question is how to access properties of an object. Seeing an actual structure is helpful.
– Brad
Nov 22 '18 at 2:05