Ask HN: Have you found a fulfilling way to handle multi-line text with JSON?

1 pointsposted 8 hours ago
by seph-reed

Item id: 47741266

1 Comments

turtleyacht

6 hours ago

This works with Ruby heredoc:

  $ irb
  query = <<-json
  { "s": "a string with
  newlines"
  }
  json
  => "{ \"s\": \"a string with\nnewlines\"\n}\n"