Loading...
「ツール」は右上に移動しました。
利用したサーバー: natural-voltaic-titanium
0いいね 64回再生

javascript - How to check if a string is a valid JSON string?

isJsonString('{ "Id": 1, "Name": "Coke" }')

should be true and
isJsonString('foo')
isJsonString('divfoo/div')

should be false.
I'm looking for a solution that doesn't use try/catch because I have my debugger set to "break on all errors" and that causes it to break on invalid JSON strings.
github.com/douglascrockford/JSON-js/blob/master/js… github.com/douglascrockford/JSON-js/blob/master/js…
comment of @Mrchief: stackoverflow.com/questions/3710204/how-to-check-i…

コメント