Can I remove the line breaks in JSON-LD?
Yes, you can use it like that. JSON-LD (resp. JSON) doesn’t define that these line breaks are meaningful.
RFC 4627, JSON Grammar:
Insignificant whitespace is allowed before or after any of the sixstructural characters.
ws = *( %x20 / ; Space %x09 / ; Horizontal tab %x0A / ; Line feed or New line %x0D ; Carriage return )