Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@harukingo

JSで多階層のJSONを扱う時の備忘録

More than 3 years have passed since last update.

経緯

 GAS使うことになった

function test() {
  var testJson = '{"replyToken":"897aa08fd48247f5aa2aa99999999999", "source":{"type":"user", "userId":"U911cc758e62b359634cd299999999999"}, "type":"message", "message":{"id":"6906513233888", "text":"なまなまか", "type":"text"}, "timestamp":"1.50917625936E12"}';
  var response = JSON.parse(testJson);
  var source = response.source;
  var s_source     = JSON.stringify(source);
  var sourceArr     = JSON.parse(s_source);
  var userId        = source.userId;
  Logger.log(source);
  Logger.log(s_source);
  Logger.log(sourceArr);
  Logger.log(userId);

}

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
harukingo
2013~2016 新卒でSIer 2017~   社内コンテンツを作るWebエンジニアに転職。勉強中

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?