0

How do I invoke the following method JsonParser:

  /**
   * Converts a JSON document to XML.
   * @param io input
   * @param options parser options
   * @return parser
   * @throws IOException I/O exception
   */
  private static IOContent toXML(final IO io, final JsonParserOptions options) throws IOException {
    final JsonConverter conv = JsonConverter.get(options);
    final IOContent xml = new IOContent(conv.convert(io).serialize().finish());
    xml.name(io.name());
    return xml;
  }

yet I'm certainly not seeing this method from the IDE:

screenshot

The method is in the JavaDocs:

Method Detail

    toXML

    public static IOContent toXML(IO io,
                  JsonParserOptions options)
                           throws java.io.IOException

    Converts a JSON document to XML.

    Parameters:
        io - input
        options - parser options
    Returns:
        parser
    Throws:
        java.io.IOException - I/O exception

The build file is using:

compile group: 'org.basex', name: 'basex', version: '9.2.4'

which is the most recent version I see on the repository:

maven { url "https://mvnrepository.com/" }

I went so far as to assemble the project and extracted the .class file from the JAR from the resulting BaseX but didn't go futher to find if this method is there or not.

Perhaps I'm just not invoking the method properly?

Thufir
  • 8,216
  • 28
  • 125
  • 273

1 Answers1

0

whoops:

package basex;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.logging.Logger;
import org.basex.build.json.JsonParser;
import org.basex.build.xml.SAXWrapper;
import org.basex.core.MainOptions;
import org.basex.io.IOFile;

public class JsonToXmlTransformer {

    private static final Logger log = Logger.getLogger(JsonToXmlTransformer.class.getName());

    public JsonToXmlTransformer() {
    }

    private void baseXparseJsonFile(String fileName) throws IOException {
        org.basex.build.json.JsonParser jsonParser = new org.basex.build.json.JsonParser(new IOFile(fileName), new MainOptions());

        SAXWrapper foo = org.basex.build.json.JsonParser.xmlParser(new IOFile(fileName));
        foo.parse();
        String bar = foo.toString();
        log.info(bar);
    }

    public void transform(String fileName) throws IOException {
        String content = new String(Files.readAllBytes(Paths.get(fileName)), StandardCharsets.UTF_8);
        org.json.JSONObject json = new org.json.JSONObject(content);
        log.info(org.json.XML.toString(json));
    }
}

had the wrong package...

Thufir
  • 8,216
  • 28
  • 125
  • 273