ParseJSONFile reads the given filename and parses it as JSON, similarly to ParseJSON. An error diagnostic is returned if the given file cannot be read.
(filename string)
| 99 | // ParseJSONFile reads the given filename and parses it as JSON, similarly to |
| 100 | // ParseJSON. An error diagnostic is returned if the given file cannot be read. |
| 101 | func (p *Parser) ParseJSONFile(filename string) (*hcl.File, hcl.Diagnostics) { |
| 102 | if existing := p.files[filename]; existing != nil { |
| 103 | return existing, nil |
| 104 | } |
| 105 | |
| 106 | file, diags := json.ParseFile(filename) |
| 107 | p.files[filename] = file |
| 108 | return file, diags |
| 109 | } |
| 110 | |
| 111 | // AddFile allows a caller to record in a parser a file that was parsed some |
| 112 | // other way, thus allowing it to be included in the registry of sources. |
no test coverage detected