--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.cms.lib.json</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
+org.eclipse.jdt.core.compiler.compliance=17
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=17
--- /dev/null
+package org.argeo.cms.acr.json;
+
+import javax.xml.namespace.QName;
+
+import org.argeo.api.acr.Content;
+import org.argeo.api.acr.NamespaceUtils;
+import org.argeo.api.acr.QNamed;
+
+import jakarta.json.stream.JsonGenerator;
+
+/** Utilities around ACR and the JSON format. */
+public class AcrJsonUtils {
+ public static void writeAttr(JsonGenerator g, Content content, String attr) {
+ writeAttr(g, content, NamespaceUtils.parsePrefixedName(attr));
+ }
+
+ public static void writeAttr(JsonGenerator g, Content content, QNamed attr) {
+ writeAttr(g, content, attr.qName());
+ }
+
+ public static void writeAttr(JsonGenerator g, Content content, QName attr) {
+ // String value = content.attr(attr);
+ Object value = content.get(attr);
+ if (value != null) {
+ // TODO specify NamespaceContext
+ String key = NamespaceUtils.toPrefixedName(attr);
+ if (value instanceof Double v)
+ g.write(key, v);
+ else if (value instanceof Long v)
+ g.write(key, v);
+ else if (value instanceof Integer v)
+ g.write(key, v);
+ else if (value instanceof Boolean v)
+ g.write(key, v);
+ else
+ g.write(key, value.toString());
+ }
+ }
+
+ /** singleton */
+ private AcrJsonUtils() {
+ }
+}