I have Strings which look like this one, but with different Id
.
[{"Id":33,"Title":"Sweden, Stockholm - Järfälla: Dienstag, 31. Januar 2017 - Mittwoch, 1. Februar 2017"}]
How can I split them so that they become:
Sweden, Stockholm - Järfälla: Dienstag, 31. Januar 2017 - Mittwoch, 1. Februar 2017
I know that I can represent the quotation marks using \"
, but I don't know how to apply the split
or String.prototype.split
function in this case.
I tried
var text = "[{\"Id\":33,\"Title\":\"Sweden, Stockholm - Järfälla: Dienstag, 31. Januar 2017 - Mittwoch, 1. Februar 2017\"}]".replace("[{\"Id\":33,\"Title\":\"", '');
alert(text);
But that would still leave "}]
at the end and besides, the Strings have different ID's so that would only work for this case.
Thanks in advance!
Use JSON.parse
var text = "[{\"Id\":33,\"Title\":\"Sweden, Stockholm - Järfälla: Dienstag, 31. Januar 2017 - Mittwoch, 1. Februar 2017\"}]"
console.log(JSON.parse(text)[0].Title.split(","))