How to use the xml-js.json2xml function in xml-js

To help you get started, we’ve selected a few xml-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-cli / packages / amplify-storage-simulator / src / server / S3server.ts View on Github external
private async handleRequestPut(request, response) {
    const directoryPath = normalize(join(String(this.localDirectoryPath), String(request.params.path)));
    ensureFileSync(directoryPath);
    // strip signature in android , returns same buffer for other clients
    var new_data = util.stripChunkSignature(request.body);
    // loading data in map for each part
    if (request.query.partNumber !== undefined) {
      this.upload_bufferMap[request.query.uploadId][request.query.partNumber] = request.body;
    } else {
      writeFileSync(directoryPath, new_data);
      // event trigger  to differentitiate between multipart and normal put
      let eventObj = this.createEvent(request);
      this.emit('event', eventObj);
    }
    response.send(xml(convert.json2xml(JSON.stringify('upload success'))));
  }
github Laverna / laverna / app / scripts / components / importExport / ImportEvernote.js View on Github external
item.name       = 'img';
                item.attributes = {
                    src: `#file:${item.attributes.hash}`,
                    alt: file.name,
                };
            }
            else {
                item.name       = 'a';
                item.attributes = {href: `#file:${item.attributes.hash}`};
                item.elements   = [{type: 'text', text: file.name}];
            }
        });
        /* eslint-enable */

        // Convert todo lists
        content = convert.json2xml(obj)
        .replace(//g, '[] ')
        .replace(//g, '[x] ');

        // Convert to Markdown
        const md = new Turndown();
        md.use(gfm);

        return md.turndown(content)
        .replace(/\n{2,}/g, '\n')
        .replace(/\\+\[/g, '[')
        .replace(/\\+\]/g, ']');
    }
github pablojorge / price-tracker / app / controllers / HTTPRequestHandler.js View on Github external
function(error, response) {
            if (error === null) {
                console.log("serveRequest: response sent:", response);
                if(req.query.as_xml) {
                    res.type('application/xml');
                    res.send(xmljs.json2xml(
                        response, {
                            compact: true,
                            ignoreComment: true,
                            spaces: 4
                        }
                    ));
                } else {
                    res.json(response);
                }
            } else {
                res.status(500);
                console.log("serverRequest: error sent: ", error.exception);
                res.json(new messages.Error(error.exception.toString(), error.info));
            }
        }
    );
github crablar / podsheets / server / src / routes / podcasts.ts View on Github external
type: "element",
                name: "itunes:category",
                attributes: {
                    text: mainCategory,
                },
                elements: subCategory.length > 0 ? [{
                    type: "element",
                    name: "itunes:category",
                    attributes: {
                        text: subCategory,
                    },
                }]
                    :
                    [],
            });
            const rssFeed = convert.json2xml(JSON.stringify(jsonFeed), {});

            res.set("Content-Type", "text/xml");
            res.send(rssFeed);
        } catch (e) {
            logger.error(e);
            return res.sendStatus(404);
        }
    });
github d14na / zeronet-explorer / src / frames / Main.js View on Github external
case 'helloWorld':
                params = [{
                    value: [{
                        string: 'boogy'
                    }, {
                        string: 'woogy'
                    }]
                }]
                break
        }

        const methodCall = { methodName, params }

        const json = { _declaration, methodCall }

        const xml = convert.json2xml(json, { compact: true, spaces: 4 })

        const apiUsername = 'dev'
        const apiPassword = 'tester'
        const encoded = Buffer.from(`${apiUsername}:${apiPassword}`).toString('base64')

        const Authorization = `Basic ${encoded}`
        const Accept = 'text/xml'

        const method = 'POST'

        const headers = { Authorization, Accept, 'Content-Type': 'text/xml' }

        const body = xml

        const fetchTarget = 'http://159.65.111.48:8442'
        const fetchOptions = { method, headers, body }
github egodigital / generator-ego / generators / app / tools.js View on Github external
toXml(obj, spaces) {
        if (arguments.length < 2) {
            spaces = 4;
        }

        return xmlJS.json2xml(obj, {
            compact: false,
            spaces: spaces,
        });
    }
github aws-amplify / amplify-cli / packages / amplify-storage-simulator / src / server / S3server.ts View on Github external
unlink(filePath, err => {
        if (err) throw err;
        response.send(xml(convert.json2xml(JSON.stringify(request.params.id + 'was deleted'))));
      });
    } else {

xml-js

A convertor between XML text and Javascript object / JSON text.

MIT
Latest version published 6 years ago

Package Health Score

65 / 100
Full package analysis