Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad String for Newline in String #29

Closed
JhonnyJason opened this issue Sep 20, 2017 · 5 comments
Closed

Bad String for Newline in String #29

JhonnyJason opened this issue Sep 20, 2017 · 5 comments

Comments

@JhonnyJason
Copy link

JhonnyJason commented Sep 20, 2017

Hello,
Having a giant hjson file containing language strings like:

"en": "hello I am a potentially very long String"

I use it as a Module inside a Javascript App - there it works perfectly in in the current way.
Using the cli it give's me the error:

Error: Bad string containing newline at line 153,106

SO basicly there are tons of these cases where I have like:

"en": "hello I am such a long string that I will become continued
in the next line"

It would be awesome if this would't be a such a big deal :-)

@laktak
Copy link
Member

laktak commented Sep 21, 2017

That's not valid JSON and I'm not sure how you are parsing this a JSON.parse() won't accept your input:

SyntaxError: Unexpected token
 in JSON at position 67
    at JSON.parse (<anonymous>)

Are you using a custom parser? You only need to replace \n by \\n to make it parseable by Hjson.

@JhonnyJason
Copy link
Author

JhonnyJason commented Sep 22, 2017

Yhea I suppose it is not valid json.
But I hoped that it is valid in hjson^^.

I'm using the Hjson.parse() from the hjson.min.js.

Probably it is an older version as I have it this way now since close to a year now.

So the issue here is either that an update in the meantime has made the parser less human friendly^^.
Or that the CLI version behaves differently from the browser version.

But yhea I guess I could do a script to get rid of the /n's within the ""s.

@laktak
Copy link
Member

laktak commented Sep 29, 2017

The problem is that you were relying on a bug that has been fixed in the meantime. Hjson supports multiline strings - I'm not sure though if that is what you want.

The easiest way is to use the old version to pipe it through - so you'll get it reformatted and it should then be working with the new version.

@laktak
Copy link
Member

laktak commented Oct 27, 2017

I hope this helped solve your problem.

@laktak laktak closed this as completed Oct 27, 2017
@JhonnyJason
Copy link
Author

yes Problem solved - thank you! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants