user3143218
user3143218

Reputation: 1816

Print JSON string without quotes and brackets

How can I print a value of an object using JSON.stringify() without the curly brackets and quote marks.

For example when I do this:

var string = "this is a string";

var test = JSON.stringify(myJsonObject);

div.innerHTML = test;

the output is this:

{"vavlue":" this is a string"}

How can I output only the actual string without anything else?

i.e :

this is a string

Upvotes: 1

Views: 5151

Answers (2)

Dylan
Dylan

Reputation: 1402

Why not just

div.innerHTML = myJsonObject.value;

Upvotes: 1

Oleg Gryb
Oleg Gryb

Reputation: 5249

If your JSON object looks like:

myJsonObject = {"vavlue":" this is a string"};

You don't need to stringify to get the string value, you can use this instead:

myJsonObject.value

Upvotes: 2

Related Questions