MCPcopy Create free account
hub / github.com/PDAL/PDAL / toJSON

Function toJSON

pdal/PDALUtils.cpp:126–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void toJSON(const MetadataNode& m, std::ostream& o, int level)
127{
128 std::string indent(level * 2, ' ');
129 std::string name = m.name();
130 std::string value = m.jsonValue();
131 bool children = m.hasChildren();
132
133 if (name.empty())
134 name = "unnamed";
135
136 // This is a case from XML. In JSON, you can't have two values.
137 if (!value.empty() && children)
138 {
139 o << indent << "\"" << name << "\": " << value << "," << std::endl;
140 o << indent << "\"" << name << "\": ";
141 subnodesToJSON(m, o, level);
142 }
143 else if (!value.empty())
144 o << indent << "\"" << name << "\": " << value;
145 else
146 {
147 o << indent << "\"" << name << "\":" << std::endl;
148 subnodesToJSON(m, o, level);
149 }
150 // There is the case where we have a name and no value to handle. What
151 // should be done?
152}
153
154} // unnamed namespace
155

Callers 15

handleMetadataVLRMethod · 0.85
readyTableMethod · 0.85
addMetadataVlrMethod · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85

Calls 7

subnodesToJSONFunction · 0.85
arrayToJSONFunction · 0.85
strMethod · 0.80
nameMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 2

TESTFunction · 0.68
TESTFunction · 0.68