mholt / json-to-go

Translates JSON into a Go type in your browser instantly (original)
https://mholt.github.io/json-to-go/
MIT License
4.48k stars 473 forks source link

About escape characters #70

Closed kevsersrca closed 4 years ago

kevsersrca commented 4 years ago

I tried json-to-go with the chrome-lighthouse json file. But struct names are not cleared, so I can't use them. Therefore I can't unmarshall json.

Example:

 "lighthouse-core/audits/is-on-https.js | title": [
        "audits[is-on-https].title"
      ],

result:

LighthouseCoreAuditsIsOnHTTPSJsTitle            []string `json:"lighthouse-core/audits/is-on-https.js 
| title"`
mholt commented 4 years ago

What is unusable about that result, exactly? It looks fine to me. Or am I missing something?

kevsersrca commented 4 years ago
`json:"lighthouse-core/audits/is-on-https.js 
| title"`

So it \n adds. therefore return error.

mholt commented 4 years ago

There is no line break when I paste your input into JSON to Go:

type AutoGenerated struct {
    LighthouseCoreAuditsIsOnHTTPSJsTitle []string `json:"lighthouse-core/audits/is-on-https.js | title"`
}

(That's a direct copy+paste)

Probably has something to do with your system.