-2

Hi I have a text string and I want to get the value Va rog sa ne trimiteti locatia out.

My text string is {"text":"Va rog sa ne trimiteti locatia"}

Thank you

Ethan Richardson
  • 461
  • 2
  • 10
  • 28
  • This is really not hard to research. What have you tried that isn't working? You are expected to show some effort to resolve problem yourself before asking questions here – charlietfl Nov 12 '16 at 14:56
  • This is trivial to Google and not what Stack Overflow is intended for. Search e.g. `node.js parse JSON` or even `node.js I have a string that I want to get the JSON value from` – Pekka Nov 12 '16 at 14:56
  • I chose the duplicate too hastily here, sorry everyone. This is a better duplicate: [How to parse JSON using Node.js?](http://stackoverflow.com/questions/5726729/how-to-parse-json-using-node-js) – Pekka Nov 12 '16 at 15:00

1 Answers1

-1

You can parse your string to object literal with JSON.parse() function:

var text = '{"text":"Va rog sa ne trimiteti locatia"}';
var obj = JSON.parse(text);
console.log(obj.text);
madox2
  • 49,493
  • 17
  • 99
  • 99
  • why downvote here? – madox2 Nov 12 '16 at 14:57
  • 2
    It can happen when answering trivial questions that can be answered by 2 seconds of Googling. Especially when the answerer has the power to close it as a duplicate of the many thousands of identical questions already floating around on SO. If you want to contribute to the question, then do that. – Pekka Nov 12 '16 at 14:58
  • Not the downvoter, but this is a very basic question and should be mark as closed as duplicate – Rajesh Nov 12 '16 at 14:58
  • that's right, but why downvote an answer? anyone can vote to close the question. – madox2 Nov 12 '16 at 14:59
  • @Pekka웃 is trying to point out that answering this is the wrong course of action and providing a duplicate would be more appropriate community action for such a poor quality question – charlietfl Nov 12 '16 at 15:02
  • @Pekka웃 So what's the point? Should I be affraid to ask an question because it might be "trivial", or should I be affraid to answer/help someone because it might be "trivial"? I don't believe that this is SO mentality – madox2 Nov 12 '16 at 15:03
  • Furthermore the "trivial" word is too relative, define it – madox2 Nov 12 '16 at 15:05
  • @madox2 flushing out very low quality questions that have no long term benefit is however proper SO mentality as well as helping to educate new users – charlietfl Nov 12 '16 at 15:05
  • @charlietfl I totally agree to close duplicate question to reduce 'junk'. But nobody can know what is asker struggling through and what is his knowledge of topic. And downvoting correct answers does not seem to be right (even if it is 'trivial'). – madox2 Nov 12 '16 at 15:13
  • Why is down voting inappropriate when one of the reasons for downvote is *"does not show any research effort"*? Hover over arrow, will even see that in the tooltip – charlietfl Nov 12 '16 at 15:15
  • You may be helping this specific asker (or enabling a [help vampire](http://meta.stackexchange.com/questions/19665)) but you're doing the community as a whole a disservice. Answering this kind of question signals that it's ok to ask them, and this kind of question coming in is a huge part of the problem why professionals feel discouraged to participate here. When I see a question like this, and I want to help the OP because I feel they are struggling, I post a comment with the solution. Or when it absolutely doesn't fit in a comment, a Community Wiki answer (that doesn't earn reputation). – Pekka Nov 12 '16 at 16:04
  • Whether it's ok to downvote a correct answer to a bad question is the subject of many discussions on Meta. There's no consensus. I believe it's ok. – Pekka Nov 12 '16 at 16:07