Closed shames0 closed 10 months ago
Did you try turning on “Repair mode” (powered by jsonrepair, which I don’t think would contaminate the original info) in “Settings → General”? It should work.
Alternatively you can create a custom script in OK JSON to convert ndjson
string to normal JSON string first. The internal conversion in OK JSON is quite simple:
public func convertNDJSONToJSON(_ string: String) -> String {
let lines = string.components(separatedBy: .newlines).filter{!$0.isEmpty}
let result = "[" + lines.joined(separator: ",") + "]"
return result
}
For more info on custom scripts, go to https://docs.okjson.app.
If you don’t want to use custom scripts in OK JSON nor the Repair mode, you can also somehow automate this with the script you already have. OK JSON has a URL Scheme that it’s well suited for this situation: okjson://paste
.
In terminal:
open "okjson://paste"
Regarding the file extensions, .jl
is recognized as source code files of the Julia language by macOS. And json
file is really a JSON file. Treating them as ndjson
is wrong in this regard.
Let me know if you have any other questions.
@francisfeng Great response. Thanks for the feedback and ideas! I've neglected the custom scripts feature completely. I'll give that a try, as well as the "Repair mode".
Thanks again!
First of all, thanks for the great app! I use it every-day and I find it to be reasonably priced, user friendly, and more performant than other tools I've tried. I've been recommending it to all my coworkers.
Is your feature request related to a problem? Please describe. I appreciate the ability to open
*.ndjson
files, but I find myself more often trying to paste ndjson content into a new OK JSON tab or window. Whenever I do this OK JSON doesn't recognize the content as valid. I get the following message:Describe the solution you'd like I'd appreciate being able to paste ndjson content (cmd+v) into an OK JSON window just as I can paste normal JSON content.
Describe alternatives you've considered My workaround for this right now is basically the following:
Additionally, there have been regular cases for me where I have been unable to open files with ndjson content seemingly due to logic around the file extension. For example, I'll get files with well-formed ndjson content in any of the following extensions:
.jl
,.json
,.txt
. When I try to open these with OK JSON I get a "failed to parse string" message. In order to open these files I have to rename them to have the.ndjson
, or.jsonl
extension. Enabling this proposed feature to be able to paste ndjson content into OK JSON would help to alleviate this inconvenience.