Package org.jlab.utils
Class JsonUtils
java.lang.Object
org.jlab.utils.JsonUtils
Stuff to read and manipulate HIPO banks with JSON objects.
- Author:
- baltzell
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic org.jlab.jnp.utils.json.JsonObjectadd(org.jlab.jnp.utils.json.JsonObject a, org.jlab.jnp.utils.json.JsonObject b) JsonObject's merge method overwrites keys of the same name, this extends.static DataBankConvenience method to create a bank containing a JsonObject.static DataBankConvenience method to create a bank containing a JsonObject.static DataBankConvenience method to create a bank containing a JsonObject.static DataBankModify event by extending bank by merging new JSON data to existing.static DataBankextend(DataEvent event, String bankName, String varName, org.jlab.jnp.utils.json.JsonObject extension) Modify event by extending bank by merging new JSON data to existing.static DataBankModify event by extending bank by merging new JSON data to existing.static DataBankThis won't be useful once DataBank.setByte(String,byte[]) is implementedstatic org.jlab.jnp.utils.json.JsonObjectJSON2Json(org.json.JSONObject json) Convert from Map to JNP's JsonObjectstatic voidstatic org.jlab.jnp.utils.json.JsonObjectConvert a map to JNP's JsonObject WARNING: presumably not generic to extended JSONs, but sufficient for configuration sections of CLARA YAMLs.static org.jlab.jnp.utils.json.JsonObjectConvenience method to get a JsonObject from a bank.static org.jlab.jnp.utils.json.JsonObjectstatic voidJust print it to the screen, nicely.static voidJust print it to the screen, nicely.static voidshow(org.jlab.jnp.utils.json.JsonObject json) Just print it to the screen, nicely.static voidshow(org.json.JSONObject json) Just print it to the screen, nicely.
- 
Constructor Details- 
JsonUtilspublic JsonUtils()
 
- 
- 
Method Details- 
showpublic static void show(org.jlab.jnp.utils.json.JsonObject json) Just print it to the screen, nicely.- Parameters:
- json-
 
- 
showpublic static void show(org.json.JSONObject json) Just print it to the screen, nicely.- Parameters:
- json-
 
- 
showJust print it to the screen, nicely.- Parameters:
- bank-
- varName-
 
- 
showJust print it to the screen, nicely.- Parameters:
- bank-
- varName-
 
- 
readConvenience method to get a JsonObject from a bank.- Parameters:
- bank- bank to read
- varName- name of byte variable to read
- Returns:
- JSON generated from array of bytes
 
- 
readpublic static org.jlab.jnp.utils.json.JsonObject read(org.jlab.jnp.hipo4.data.Bank bank, String varName) 
- 
fillThis won't be useful once DataBank.setByte(String,byte[]) is implemented- Parameters:
- bank- bank to modify
- varName- name of bank byte variable to modify
- contents- contents of the variable, one byte per row
- Returns:
- the input bank after modification
 
- 
Map2JsonConvert a map to JNP's JsonObject WARNING: presumably not generic to extended JSONs, but sufficient for configuration sections of CLARA YAMLs.- Parameters:
- map-
- Returns:
 
- 
JSON2Jsonpublic static org.jlab.jnp.utils.json.JsonObject JSON2Json(org.json.JSONObject json) Convert from Map to JNP's JsonObject- Parameters:
- json- an org.json.JSONObject
- Returns:
- the corresponding org.jlab.jnp.utils.json.JsonObject
 
- 
createpublic static DataBank create(DataEvent event, String bankName, String varName, org.jlab.jnp.utils.json.JsonObject json) Convenience method to create a bank containing a JsonObject.- Parameters:
- event- event used to generate the bank
- bankName- name of bank to create
- varName- name of variable to put the JSON object in
- json- contents for the variable
- Returns:
- new bank
 
- 
createpublic static DataBank create(DataEvent event, String bankName, String varName, org.json.JSONObject json) Convenience method to create a bank containing a JsonObject.- Parameters:
- event- event used to generate the bank
- bankName- name of bank to create
- varName- name of variable to put the JSON object in
- json- contents for the variable
- Returns:
- new bank
 
- 
createConvenience method to create a bank containing a JsonObject.- Parameters:
- event- event used to generate the bank
- bankName- name of bank to create
- varName- name of variable to put the JSON object in
- json- contents for the variable
- Returns:
- new bank
 
- 
addpublic static org.jlab.jnp.utils.json.JsonObject add(org.jlab.jnp.utils.json.JsonObject a, org.jlab.jnp.utils.json.JsonObject b) JsonObject's merge method overwrites keys of the same name, this extends. WARNING: presumably not generic to extended JSONs, but sufficient for configuration sections of CLARA YAMLs.- Parameters:
- a-
- b-
- Returns:
- a+b
 
- 
extendpublic static DataBank extend(DataEvent event, String bankName, String varName, org.jlab.jnp.utils.json.JsonObject extension) Modify event by extending bank by merging new JSON data to existing. If bank doesn't exist, create it.- Parameters:
- event- event to get the bank from and put it back into
- bankName- name of bank
- varName- name of variable within bank
- extension- JSON object to extend with
- Returns:
 
- 
extendpublic static DataBank extend(DataEvent event, String bankName, String varName, org.json.JSONObject extension) Modify event by extending bank by merging new JSON data to existing. If bank doesn't exist, create it.- Parameters:
- event- event to get the bank from and put it back into
- bankName- name of bank
- varName- name of variable within bank
- extension- JSON object to extend with
- Returns:
 
- 
extendpublic static DataBank extend(DataEvent event, String bankName, String varName, Map<String, Object> extension) Modify event by extending bank by merging new JSON data to existing. If bank doesn't exist, create it.- Parameters:
- event- event to get the bank from and put it back into
- bankName- name of bank
- varName- name of variable within bank
- extension- JSON object to extend with
- Returns:
 
- 
main
 
-