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 six structural characters.
ws = *(
%x20 / ; Space
%x09 / ; Horizontal tab
%x0A / ; Line feed or New line
%x0D ; Carriage return
)