Class JSONEditor
- java.lang.Object
- 
- edu.uiuc.ncsa.security.util.cli.AbstractEditor
- 
- edu.uiuc.ncsa.security.util.cli.json_edit.JSONEditor
 
 
- 
 public class JSONEditor extends AbstractEditor An editor for JSON objects. Mostly an experiment to see if this is viable for large JSON objects.Created by Jeff Gaynor 
 on 8/17/20 at 10:26 AM
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classJSONEditor.formatRecord
 - 
Field SummaryFields Modifier and Type Field Description static StringADD_NODEstatic StringCHANGE_NODEstatic StringCURRENT_NODEstatic StringDELETE_NODEstatic StringFILE_FLAGstatic StringFILE_LOADstatic StringFILE_SAVEstatic StringFORMAT_TYPE_BOOLEANstatic StringFORMAT_TYPE_JSON_ARRAYstatic StringFORMAT_TYPE_JSON_OBJECTstatic StringFORMAT_TYPE_NULLstatic StringFORMAT_TYPE_NUMBERstatic StringFORMAT_TYPE_STRINGstatic StringFORMAT_TYPE_UNKNOWNstatic StringLIST_NODEstatic StringPRINT_RAW_FLAGprotected static intRC_CONTINUEprotected static intRC_EXITprotected static intRC_NO_OPprotected static intRC_OKstatic StringSET_NODE_VALUEstatic StringTREE_COMMANDprotected StringTREE_PIPEprotected StringTREE_PLUSprotected static StringTYPE_FLAGprotected static StringVALUE_FLAG- 
Fields inherited from class edu.uiuc.ncsa.security.util.cli.AbstractEditorHELP_COMMAND, isDone, PROMPT, QUIT_COMMAND, QUIT_COMMAND_LONG, VERBOSE_COMMAND, VERBOSE_COMMAND_LONG, verboseOn
 
- 
 - 
Constructor SummaryConstructors Constructor Description JSONEditor()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int_doAddNode(EditorInputLine eil)protected void_doChangeNode(EditorInputLine eil)protected void_doCurrentNode()protected int_doFileSave(EditorInputLine eil)protected int_doListNode(EditorInputLine eil)protected int_doVerbose(EditorInputLine eil)protected voidaddNodeHelp()protected ObjectconvertByType(String type, String rawValue)voidexecute()protected net.sf.json.JSONfileToJSON(String filename)protected StringfileToString(String fileName)protected StringformatScalar(Object object)protected StringformatSingleEntry(String key, Object obj)Entries look likenet.sf.json.JSONgetCurrentObject()protected StringgetEntryType(Object obj)protected voidinsertNode(net.sf.json.JSONObject json, net.sf.json.JSON node, String path)protected voidlistNodeHelp()static voidmain(String[] args)protected net.sf.json.JSONnavigate(String[] path)Navigates to the next to last component for a full path.protected voidprintArrayTree(String indent, String nodeName, net.sf.json.JSONArray array)protected voidprintObjectTree(String indent, String nodeName, net.sf.json.JSONObject jsonObject)protected voidprintRecords(List<JSONEditor.formatRecord> formatRecordList, boolean rawOnly)protected voidprintTypes()voidsetCurrentObject(net.sf.json.JSON currentObject)protected voidshowFileSaveHelp()protected voidwriteToFile(String filename, String contents)- 
Methods inherited from class edu.uiuc.ncsa.security.util.cli.AbstractEditorgetIoInterface, readline, say, sayi, sayv, setIoInterface, showHelp, verboseHelp
 
- 
 
- 
- 
- 
Field Detail- 
CHANGE_NODEpublic static final String CHANGE_NODE - See Also:
- Constant Field Values
 
 - 
LIST_NODEpublic static final String LIST_NODE - See Also:
- Constant Field Values
 
 - 
CURRENT_NODEpublic static final String CURRENT_NODE - See Also:
- Constant Field Values
 
 - 
ADD_NODEpublic static final String ADD_NODE - See Also:
- Constant Field Values
 
 - 
DELETE_NODEpublic static final String DELETE_NODE - See Also:
- Constant Field Values
 
 - 
SET_NODE_VALUEpublic static final String SET_NODE_VALUE - See Also:
- Constant Field Values
 
 - 
TREE_COMMANDpublic static final String TREE_COMMAND - See Also:
- Constant Field Values
 
 - 
FILE_LOADpublic static final String FILE_LOAD - See Also:
- Constant Field Values
 
 - 
FILE_SAVEpublic static final String FILE_SAVE - See Also:
- Constant Field Values
 
 - 
RC_CONTINUEprotected static int RC_CONTINUE 
 - 
RC_EXITprotected static int RC_EXIT 
 - 
RC_OKprotected static int RC_OK 
 - 
RC_NO_OPprotected static int RC_NO_OP 
 - 
TREE_PIPEprotected String TREE_PIPE 
 - 
TREE_PLUSprotected String TREE_PLUS 
 - 
FILE_FLAGpublic static final String FILE_FLAG - See Also:
- Constant Field Values
 
 - 
TYPE_FLAGprotected static String TYPE_FLAG 
 - 
VALUE_FLAGprotected static String VALUE_FLAG 
 - 
PRINT_RAW_FLAGpublic static final String PRINT_RAW_FLAG - See Also:
- Constant Field Values
 
 - 
FORMAT_TYPE_JSON_OBJECTpublic static final String FORMAT_TYPE_JSON_OBJECT - See Also:
- Constant Field Values
 
 - 
FORMAT_TYPE_JSON_ARRAYpublic static final String FORMAT_TYPE_JSON_ARRAY - See Also:
- Constant Field Values
 
 - 
FORMAT_TYPE_BOOLEANpublic static final String FORMAT_TYPE_BOOLEAN - See Also:
- Constant Field Values
 
 - 
FORMAT_TYPE_NUMBERpublic static final String FORMAT_TYPE_NUMBER - See Also:
- Constant Field Values
 
 - 
FORMAT_TYPE_STRINGpublic static final String FORMAT_TYPE_STRING - See Also:
- Constant Field Values
 
 - 
FORMAT_TYPE_NULLpublic static final String FORMAT_TYPE_NULL - See Also:
- Constant Field Values
 
 - 
FORMAT_TYPE_UNKNOWNpublic static final String FORMAT_TYPE_UNKNOWN - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getCurrentObjectpublic net.sf.json.JSON getCurrentObject() 
 - 
setCurrentObjectpublic void setCurrentObject(net.sf.json.JSON currentObject) 
 - 
executepublic void execute() throws Throwable- Overrides:
- executein class- AbstractEditor
- Throws:
- Throwable
 
 - 
showFileSaveHelpprotected void showFileSaveHelp() 
 - 
writeToFileprotected void writeToFile(String filename, String contents) throws IOException - Throws:
- IOException
 
 - 
_doFileSaveprotected int _doFileSave(EditorInputLine eil) 
 - 
insertNodeprotected void insertNode(net.sf.json.JSONObject json, net.sf.json.JSON node, String path)
 - 
fileToJSONprotected net.sf.json.JSON fileToJSON(String filename) throws IOException - Throws:
- IOException
 
 - 
fileToStringprotected String fileToString(String fileName) throws IOException - Throws:
- IOException
 
 - 
printObjectTreeprotected void printObjectTree(String indent, String nodeName, net.sf.json.JSONObject jsonObject) 
 - 
printArrayTreeprotected void printArrayTree(String indent, String nodeName, net.sf.json.JSONArray array) 
 - 
addNodeHelpprotected void addNodeHelp() 
 - 
_doAddNodeprotected int _doAddNode(EditorInputLine eil) 
 - 
listNodeHelpprotected void listNodeHelp() 
 - 
navigateprotected net.sf.json.JSON navigate(String[] path) Navigates to the next to last component for a full path. If this returns a null, then there was no such path- Parameters:
- path-
- Returns:
 
 - 
_doListNodeprotected int _doListNode(EditorInputLine eil) 
 - 
_doCurrentNodeprotected void _doCurrentNode() 
 - 
_doVerboseprotected int _doVerbose(EditorInputLine eil) 
 - 
_doChangeNodeprotected void _doChangeNode(EditorInputLine eil) 
 - 
mainpublic static void main(String[] args) 
 - 
printTypesprotected void printTypes() 
 - 
formatSingleEntryprotected String formatSingleEntry(String key, Object obj) Entries look likekey | type | entrytypes are+ = JSON object * = array b = boolean n = number s = string- Parameters:
- obj-
- Returns:
 
 - 
printRecordsprotected void printRecords(List<JSONEditor.formatRecord> formatRecordList, boolean rawOnly) 
 
- 
 
-