Create new json file in pretty print format

Answered

Hello everyone,

I'm writing a small plugin for generating mock data, where as a result I get a JSON object and I need to save it to a file.
I do it this way:

file = psiFileFactory.createFileFromText("stub.json", JsonFileType.INSTANCE,  JSON.std.asString(finalStub));
directory.add(file);

 but the Json is saved in a string format, is there some option to use PsiFileFactory that allows you to do a PrettyPrint and save the Json object not as a string?

0
2 comments

You can use com.intellij.psi.codeStyle.CodeStyleManager to reformat the generated PsiFile's contents.

0

Please sign in to leave a comment.