18#ifndef vtkMRMLJsonElement_h
19#define vtkMRMLJsonElement_h
22#include "vtkSmartPointer.h"
28class vtkXMLDataElement;
37 void PrintSelf(ostream& os, vtkIndent indent)
override;
210 std::string
ConvertJsonToXML(
const std::string& jsonString,
const std::string& nodeTagName);
292 std::string
ConvertXMLToJson(vtkXMLDataElement* xmlElement,
const std::string& nodeTagName);
Simple class for storing standard coded entries (coding scheme, value, meaning triplets)
Represents a json object or list.
int GetObjectSize()
Returns the number of elements in this object.
bool GetStringProperty(const char *propertyName, std::string &propertyValue)
std::string GetSchema()
Get the JSON schema name.
bool GetArrayItemsStringProperty(const char *arrayName, const char *propertyName, std::vector< std::string > &propertyValues)
bool GetDoubleProperty(const char *propertyName, double &propertyValue)
double GetDoubleProperty(const char *propertyName)
VTK_NEWINSTANCE vtkMRMLJsonElement * GetArrayItem(int childItemIndex)
VTK_NEWINSTANCE vtkMRMLJsonElement * GetObjectProperty(const char *objectName)
static vtkMRMLJsonElement * New()
VTK_NEWINSTANCE vtkMRMLJsonElement * GetObjectItem(int childItemIndex)
std::string GetStringProperty(const char *propertyName)
VTK_NEWINSTANCE vtkMRMLJsonElement * GetChildMemberItem(int childItemIndex)
int GetArraySize()
Returns the number of elements in this array.
friend class vtkMRMLJsonReader
bool IsArray()
Returns true if this element is an array.
~vtkMRMLJsonElement() override
void PrintSelf(ostream &os, vtkIndent indent) override
std::string GetObjectPropertyNameByIndex(int childItemIndex)
Get object member name by index.
bool HasErrors()
Returns true if user messages contain error messages.
vtkNew< vtkMRMLMessageCollection > UserMessages
bool GetIntProperty(const char *propertyName, int &propertyValue)
bool GetVectorProperty(const char *propertyName, double *v, int numberOfComponents=3)
void operator=(const vtkMRMLJsonElement &)
VTK_NEWINSTANCE vtkDoubleArray * GetDoubleArrayProperty(const char *propertyName)
int GetIntProperty(const char *propertyName)
bool GetBoolProperty(const char *propertyName)
Get Boolean property value.
VTK_NEWINSTANCE vtkMRMLJsonElement * GetArrayProperty(const char *arrayName)
static const std::string XML_SEPARATOR
bool HasMember(const char *propertyName)
Returns true if the JSON object contains a member by this name.
bool GetStringVectorProperty(const char *propertyName, std::vector< std::string > &arrayValues)
Type GetMemberType(const char *propertyName)
bool IsObject()
Returns true if this element is an object.
vtkMRMLJsonElement(const vtkMRMLJsonElement &)
bool GetMatrix4x4Property(const char *propertyName, double v[16], bool flipRasLps)
VTK_NEWINSTANCE vtkCodedEntry * GetCodedEntryProperty(const char *propertyName)
static const std::string XML_NAME_VALUE_SEPARATOR
bool GetBoolProperty(const char *propertyName, bool &propertyValue)
Type GetType()
Returns this element type.
bool HasErrors()
Returns true if user messages contain error messages.
void PrintSelf(ostream &os, vtkIndent indent) override
VTK_NEWINSTANCE vtkMRMLJsonElement * ReadFromString(const std::string &jsonString)
std::string processJsonElement(vtkMRMLJsonElement *jsonElement, const std::string &elementKey="")
static vtkMRMLJsonReader * New()
vtkMRMLJsonReader(const vtkMRMLJsonReader &)
~vtkMRMLJsonReader() override
VTK_NEWINSTANCE vtkMRMLJsonElement * ReadFromFile(const char *filePath)
void operator=(const vtkMRMLJsonReader &)
std::string ConvertJsonToXML(const std::string &jsonString, const std::string &nodeTagName)
vtkNew< vtkMRMLMessageCollection > UserMessages
std::string ConvertXMLToJson(vtkXMLDataElement *xmlElement, const std::string &nodeTagName)
void WriteStringProperty(const std::string &propertyName, const std::string &propertyValue)
void PrintSelf(ostream &os, vtkIndent indent) override
void processXMLElement(vtkXMLDataElement *xmlElement)
void WriteIntProperty(const std::string &propertyName, int propertyValue)
void WriteBoolProperty(const std::string &propertyName, bool propertyValue)
std::string toLower(const std::string &str)
Utility function to convert string to lower case.
void WriteStringPropertyIfNotEmpty(const std::string &propertyName, const std::string &propertyValue)
vtkMRMLJsonWriter(const vtkMRMLJsonWriter &)
void WriteArrayPropertyEnd()
This method must be called when all array items are written.
~vtkMRMLJsonWriter() override
void WriteDoubleProperty(const std::string &propertyName, double propertyValue)
void WriteObjectPropertyStart(const std::string &propertyName)
This method creates a new object as a property.
void WriteObjectPropertyEnd()
This method must be called when all properties of the object are written.
void WriteCodedEntryProperty(const std::string &propertyName, vtkCodedEntry *codedEntry)
void WriteObjectStart()
This method creates a new object in an array.
bool isBool(const std::string &str)
Utility functions to check string type.
static vtkMRMLJsonWriter * New()
void WriteDoubleArrayProperty(const char *propertyName, vtkDoubleArray *doubleArray)
void WriteVectorProperty(const std::string &propertyName, double *v, int numberOfComponents=3)
void WriteArrayPropertyStart(const std::string &propertyName)
This method creates a new array as a property.
bool WriteToStringBegin(const char *nodeTagName)
bool WriteToFileBegin(const char *filePath, const char *schema)
bool isInt(const std::string &str)
void WriteStringVectorProperty(const std::string &propertyName, const std::vector< std::string > &arrayValues)
std::string WriteToStringEnd()
bool HasErrors()
Returns true if user messages contain error messages.
void WriteMatrix4x4Property(const std::string &propertyName, double v[16], bool flipRasLps)
void operator=(const vtkMRMLJsonWriter &)
vtkNew< vtkMRMLMessageCollection > UserMessages
void WriteObjectEnd()
This method must be called when all properties of the object are written.
bool isDouble(const std::string &str)