LoginSignup
0
0

More than 1 year has passed since last update.

【GAS】JSON形式のテキストをJSONデータとして扱いたい

Posted at

目次

1. スクリプト
2. 実行結果

1. スクリプト

getDataFromJsonString.js
function test() {
  var jsonString = "{ 'title' : '件名', 'body' : '本文' }"
  getDataFromJsonString(jsonString);
}

function getDataFromJsonString(jsonString) {
  var jsonString = jsonString.replace(/'/g, '"');
  var json = JSON.parse(jsonString)
  var title = json['title']
  Logger.log(title)
}

2. 実行結果

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0