Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JSON.stringify()

 JSON.stringify()

JSON日の金曜日 #12の発表資料

Matsui Masashi

September 13, 2019
Tweet

More Decks by Matsui Masashi

Other Decks in Programming

Transcript

  1. JSON.stringify()
    @circled9
    2019-09-13
    Friday 13 JSON #12


    View full-size slide

  2. Matsui Masashi
    দҪਖ਼ࢤ DJSDMFE
    ϒϥ΢β͕޷͖ͳਓ
    !XBUFSDFMMJOD
    !3

    View full-size slide

  3. JSON.stringify()


    View full-size slide

  4. JSON.stringify() is …
    • JavaScriptͷؔ਺
    • ΦϒδΣΫτΛJSONʹม׵͢Δ
    • JSONΦϒδΣΫτͷ࣋ͭؔ਺ͷதͰ3ຊͷࢦ
    ʹೖΔਓؾͷؔ਺


    View full-size slide

  5. JSON.stringify(value[, replacer[, space]])


    View full-size slide

  6. arguments
    • value
    • any
    • replacer: optional
    • Array | function
    • space: optional
    • String | Number


    View full-size slide

  7. value
    • JSONจࣈྻʹม׵͢Δ஋ɻ


    View full-size slide

  8. replacer
    • ग़ྗ͢ΔJSONจࣈྻͷ੍ޚΛߦ͏
    • Array
    • JSONจࣈྻʹؚΊΔϗϫΠτϦετ
    • Function: function(key, value)
    • JSONจࣈྻʹม׵͢Δ࣌ͷؔ਺


    View full-size slide

  9. space
    • ग़ྗ͢ΔJSONจࣈྻͷۭനΛ੍ޚ͢Δ
    • Number
    • ۭനจࣈͷ਺
    • String
    • ۭനͱͯ͠࢖༻͢Δจࣈྻ


    View full-size slide

  10. ·ͱΊ
    • JSON.stringify() ͸JSONΦϒδΣΫτͷؔ਺
    ͷதͰ3ຊͷࢦʹೖΔਓؾͷؔ਺
    • ୈ2Ҿ਺͕࣮͸ߴػೳ
    • Ͱ΋ɺ݁ہ JSON.stringify(obj, null, 2) Ҏ֎
    ࢖͏͜ͱ͸΄ͱΜͲͳ͍


    View full-size slide