@Singleton
public class JsonUtils
extends java.lang.Object
JsonObjectMapper
.Modifier and Type | Class and Description |
---|---|
static class |
JsonUtils.JsonForApi |
static class |
JsonUtils.JsonForIO
Helper class for selectively marshaling an Object to JSON.
|
static class |
JsonUtils.JsonForPublix
Helper class for selectively marshaling an Object to JSON.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DATA |
static java.lang.String |
VERSION |
Constructor and Description |
---|
JsonUtils() |
Modifier and Type | Method and Description |
---|---|
com.fasterxml.jackson.databind.JsonNode |
allBatchesByStudyForUI(java.util.List<Batch> batchList,
java.util.List<java.lang.Integer> resultCountList,
java.util.List<java.lang.Integer> groupCountList)
Returns a JSON string of all batches that belong to the given study.
|
com.fasterxml.jackson.databind.JsonNode |
allComponentsForUI(java.util.List<Component> componentList,
java.util.List<java.lang.Integer> resultCountList)
Returns a JSON string of all components in the given list.
|
com.fasterxml.jackson.databind.JsonNode |
allGroupResultsForUI(java.util.List<GroupResult> groupResultList)
Returns all GroupResults as a JSON string intended for GUI.
|
static java.lang.String |
asJson(java.lang.Object obj)
Generic JSON marshaller.
|
com.fasterxml.jackson.databind.JsonNode |
asJsonForApi(java.lang.Object obj) |
java.lang.String |
asJsonForPublix(java.lang.Object obj)
Marshalling an Object into an JSON string.
|
static com.fasterxml.jackson.databind.JsonNode |
asJsonNode(java.lang.Object obj)
Generic JSON marshaller.
|
static java.lang.String |
asStringForDB(java.lang.String jsonData)
Formats a JSON string into a minimized form suitable for storing into a
DB.
|
com.fasterxml.jackson.databind.JsonNode |
componentResultAsJsonNode(ComponentResult cr)
Returns an ObjectNode of the given ComponentResult.
|
java.lang.String |
componentResultDataShortForUI(ComponentResult result)
Returns ComponentResult.dataShort limited to MAX_CHAR_PER_RESULT characters.
|
com.fasterxml.jackson.databind.node.ObjectNode |
componentResultMetadata(ComponentResult cr) |
com.fasterxml.jackson.databind.node.ObjectNode |
getBatchByStudyForUI(Batch batch,
java.lang.Integer resultCount,
java.lang.Integer groupCount)
Returns a JSON string of one batch.
|
com.fasterxml.jackson.databind.JsonNode |
getComponentResultsByStudyResult(StudyResult studyResult) |
java.util.Map<java.lang.String,java.lang.Object> |
getSingleUserData(User user) |
com.fasterxml.jackson.databind.JsonNode |
initData(Batch batch,
StudyResult studyResult,
Study study,
Component component)
Returns init data that are requested during initialisation of each
component run: Marshals the study properties and the component properties
and puts them together with the session data (stored in StudyResult) into
a new JSON object.
|
static boolean |
isValid(java.lang.String json)
Checks whether the given string is a valid JSON string.
|
com.fasterxml.jackson.databind.JsonNode |
memberUserArrayOfStudy(java.util.List<User> userList,
Study study)
Returns JsonNode with all users of this study.
|
com.fasterxml.jackson.databind.node.ObjectNode |
memberUserOfStudy(User user,
Study study)
Returns JsonNode with the given user.
|
com.fasterxml.jackson.databind.JsonNode |
sidebarData(java.util.List<Study> studyList)
Returns the JSON data for the sidebar (study title, ID and components)
|
com.fasterxml.jackson.databind.JsonNode |
studyAsJsonForApi(Study study,
java.lang.Boolean withComponentProperties,
java.lang.Boolean withBatchProperties)
Returns JSON of a study intended for the JATOS API
|
void |
studyAsJsonForIO(Study study,
java.io.File file)
Marshals the given study into JSON, adds the current study serial
version, and saves it into the given File.
|
com.fasterxml.jackson.databind.JsonNode |
studyLinksData(java.util.List<StudyLink> studyLinkList) |
com.fasterxml.jackson.databind.JsonNode |
studyLinksSetupData(Batch batch,
java.util.Map<java.lang.String,java.lang.Integer> studyResultCountsPerWorker,
java.lang.Integer personalSingleLinkCount,
java.lang.Integer personalMultipleLinkCount) |
com.fasterxml.jackson.databind.node.ObjectNode |
studyResultAsJsonNode(StudyResult sr,
java.lang.Integer componentResultCount)
Returns ObjectNode of the given StudyResult.
|
com.fasterxml.jackson.databind.node.ObjectNode |
studyResultMetadata(StudyResult sr) |
static com.fasterxml.jackson.databind.JsonNode |
wrapForApi(com.fasterxml.jackson.databind.JsonNode jsonNode) |
static com.fasterxml.jackson.databind.JsonNode |
wrapForApi(com.fasterxml.jackson.databind.JsonNode jsonNode,
java.util.Map<java.lang.String,java.lang.Object> fields) |
static com.fasterxml.jackson.databind.JsonNode |
wrapNodeInObject(com.fasterxml.jackson.databind.JsonNode jsonNode,
java.util.Map<java.lang.String,java.lang.Object> fields) |
public static final java.lang.String DATA
public static final java.lang.String VERSION
public java.lang.String asJsonForPublix(java.lang.Object obj) throws com.fasterxml.jackson.core.JsonProcessingException
com.fasterxml.jackson.core.JsonProcessingException
public com.fasterxml.jackson.databind.JsonNode asJsonForApi(java.lang.Object obj) throws java.io.IOException
java.io.IOException
public static java.lang.String asStringForDB(java.lang.String jsonData)
public static boolean isValid(java.lang.String json)
public com.fasterxml.jackson.databind.JsonNode initData(Batch batch, StudyResult studyResult, Study study, Component component) throws java.io.IOException
java.io.IOException
public com.fasterxml.jackson.databind.JsonNode allGroupResultsForUI(java.util.List<GroupResult> groupResultList)
public java.lang.String componentResultDataShortForUI(ComponentResult result)
public com.fasterxml.jackson.databind.node.ObjectNode studyResultMetadata(StudyResult sr) throws java.io.IOException
java.io.IOException
public com.fasterxml.jackson.databind.node.ObjectNode studyResultAsJsonNode(StudyResult sr, java.lang.Integer componentResultCount)
public com.fasterxml.jackson.databind.JsonNode getComponentResultsByStudyResult(StudyResult studyResult)
public com.fasterxml.jackson.databind.node.ObjectNode componentResultMetadata(ComponentResult cr)
public com.fasterxml.jackson.databind.JsonNode componentResultAsJsonNode(ComponentResult cr)
public com.fasterxml.jackson.databind.JsonNode memberUserArrayOfStudy(java.util.List<User> userList, Study study)
public com.fasterxml.jackson.databind.node.ObjectNode memberUserOfStudy(User user, Study study)
public java.util.Map<java.lang.String,java.lang.Object> getSingleUserData(User user)
public com.fasterxml.jackson.databind.JsonNode sidebarData(java.util.List<Study> studyList)
public com.fasterxml.jackson.databind.JsonNode allBatchesByStudyForUI(java.util.List<Batch> batchList, java.util.List<java.lang.Integer> resultCountList, java.util.List<java.lang.Integer> groupCountList)
public com.fasterxml.jackson.databind.node.ObjectNode getBatchByStudyForUI(Batch batch, java.lang.Integer resultCount, java.lang.Integer groupCount)
public com.fasterxml.jackson.databind.JsonNode allComponentsForUI(java.util.List<Component> componentList, java.util.List<java.lang.Integer> resultCountList)
public com.fasterxml.jackson.databind.JsonNode studyLinksSetupData(Batch batch, java.util.Map<java.lang.String,java.lang.Integer> studyResultCountsPerWorker, java.lang.Integer personalSingleLinkCount, java.lang.Integer personalMultipleLinkCount)
public com.fasterxml.jackson.databind.JsonNode studyLinksData(java.util.List<StudyLink> studyLinkList)
public static java.lang.String asJson(java.lang.Object obj)
public static com.fasterxml.jackson.databind.JsonNode asJsonNode(java.lang.Object obj)
public void studyAsJsonForIO(Study study, java.io.File file) throws java.io.IOException
java.io.IOException
public com.fasterxml.jackson.databind.JsonNode studyAsJsonForApi(Study study, java.lang.Boolean withComponentProperties, java.lang.Boolean withBatchProperties) throws java.io.IOException
java.io.IOException
public static com.fasterxml.jackson.databind.JsonNode wrapForApi(com.fasterxml.jackson.databind.JsonNode jsonNode)
public static com.fasterxml.jackson.databind.JsonNode wrapForApi(com.fasterxml.jackson.databind.JsonNode jsonNode, java.util.Map<java.lang.String,java.lang.Object> fields)
public static com.fasterxml.jackson.databind.JsonNode wrapNodeInObject(com.fasterxml.jackson.databind.JsonNode jsonNode, java.util.Map<java.lang.String,java.lang.Object> fields)