jsonix | Powerful XML < - > JSON JavaScript mapping library
kandi X-RAY | jsonix Summary
kandi X-RAY | jsonix Summary
See also the other Jsonix features.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- step 2 .
- recursive function
- load a module
- define functions
- Call this function
- the main loop
- creates a new object
- inject a function .
- no - op
- iterate over a and b
jsonix Key Features
jsonix Examples and Code Snippets
Community Discussions
Trending Discussions on jsonix
QUESTION
According to the wiki page of Jsonix regarding its support for xsi:type
:
When marshalling, Jsonix checks, if the value has the same type as declared in the property or element declaration
I'm wondering if there is a way to explicitly get Jsonix to generate that attribute? I was able to do that in another project by specifying the TYPE_NAME
property, i.e.
ANSWER
Answered 2019-Oct-22 at 07:08In your example, your unmarshalled Title
has the type Mappings.SomeType
, which matches your mappings. So Jsonix does not need to output xsi:type
as there's a match.
If I understand you correctly, you want Jsonix to always output xsi:type
. Not sure why you need this, but this is not supported OOTB.
You will probably need to patch Jsonix to get this. Here is where Jsonix decides whether to add xsi:type
or not:
Since I don't quite see the need of forcing xsi:type
output in general, I don't think this functionality should be included in Jsonix. So you'll probably end up with your own fork.
QUESTION
I have several XSD files, separated by requests and subjects, however the JSON Schema that I get as an output is one big file with thousands of lines. I would like to know if there is a setting to output the generated JSON Schema as several files using Jsonix. It would be easier to navigate in.
Below is the Jsonix part of my pom.xml:
...ANSWER
Answered 2019-Sep-04 at 07:58Author of Jsonix here.
I would like to know if there is a setting to output the generated JSON Schema as several files using Jsonix.
Yes, please read about modules and mappings.
In short a mapping more-or-less corresponds to one package in Java. A module is a collection of one or more mappings, is also a unit of generation.
You can configure the compiler to generate modules containing specific mappings.
If I understand your case correctly, you have a large schema and you'd like to divide mappings or JSON schemas into several files.
Here's how I'd approach it.
- Configure several mappings for your schema. You can specify exactly which type, elements, etc. go in which mappings. See includes configuration for this. Make sure to give your mappings unique names.
- Condigure several modules each of which would contain a subset of mappings.
I have to say I haven't really tried it in this scenario. Normally people do the opposite thing - group several mappings in one module. But I see no reason for this not to work.
An example configuration might look something like:
QUESTION
How can I use Jsonix in Google Apps Script (server side Google Docs automation)? If I can't, what's an alternate to Jsonix I can use in GAS to generate Javascript mappings from XSD, then serialize a JS object to XML for submission to a REST API, then deserialize the response back into a JS object?
I used Jsonix to compile a REST API from its XSD files to JSON mappings. I tested OK in commandline Node.js a Javascript that creates a JS object from inline JSON, then marshals it under the Jsonix.Context for submisstion to the REST API, then unmarshals the response.
Then I created a Google Apps Script project with my script. I created another GAS project with the Jsonix.js script (as Jsonix.gs), then another GAS project with the mappings script (as API.gs). I configured my main script's project Resources with the Jsonix and API libraries' project keys. I can execute my script (verifying the library resources are used), but it fails when Jsonix.createDocument()
is called. I inserted into the beginning of the Jsonix library script's _jsonix_factory = function(_jsonix_xmldom, _jsonix_xmlhttprequest, _jsonix_fs)
a Logger.log("_jsonix_xmldom: " + _jsonix_xmldom)
line that logs _jsonix_xmldom: undefined
, which is why Jsonix.createDocument()
throws an error instead of returning a document.
Can I use the Google Apps Script service XmlService, or some other service in the GAS environment, instead of the _jsonix_xmldom that Jsonix expects by default? Or can I include as a library resource some functionally equivalent libraries? Or otherwise supply that functionality to Jsonix in GAS?
I expect that similar errors will result from Jsonix trying to use the _jsonix_xmlhttprequest
and _jsonix_fs
values that are also undefined. I see in the Jsonix.js (.gs) source code the two lines
// REWORK
// Node.js
in the createDocument()
declaration and elsewhere. Perhaps this case I'm reporting is in active development?
Thanks for your insights.
...ANSWER
Answered 2018-Aug-23 at 19:07I wound up creating new Google Apps Script projects for Jsonix, for its XMLDOM dependency, and for my API mappings JS (GAS) that I generated with Jsonix from the API's XSD files. I made my GAS Jsonix project depend on my XMLDOM project as a library resource. Then I made a GAS project for my main script, which depends on the Jsonix GAS project and the API GAS project as library resources. It works.
I used an existing, well tested XMLDOM project with an appropriate FOSS license, and tweaked it to fit the GAS API requirements.
I tried using the GAS XmlService, wrapping its API to present its relevant members as DOMImplementation, DOMParser and XMLSerializer, but the the XmlService API is deeply inconsistent with the XMLDOM API. The XmlService API's members corresponding to the standard DOM implementation's are structured not at all consistently with the standard API.
QUESTION
I am using Jsonix, I have used below mentioned command to generate jsonix mapping and jsonix schema as,
...ANSWER
Answered 2018-Feb-20 at 11:03The change of exclusiveMaximum
from boolean to number happened with Draft-06/07 of JSON Schema.
QUESTION
I am using JSONIX to marshall and unmarshall XML received from other system. The XML I want to marshall and unmarshall
392.2361
392.24
I still cannot figure out how to unmarshall the value "392.2361". Any one with any idea? Thanks in advance
...ANSWER
Answered 2017-Dec-11 at 07:24What you need here is a mixed property.
QUESTION
Newbie to Node.js - and maybe this is a dumb question. I'm a C# developer . I am generating javascript schema from xsd files - then I want to create xml files from that using jsonix.
Question: Can I somehow get intellisense for the object generated so I can fill out the details easily? I'm using visual studio but we have webstorm etc.
Thanks in advance :-)
...ANSWER
Answered 2017-Oct-27 at 07:24Author of Jsonix here.
As far as I know there's no possibility for Intellisense (or likes) at the moment.
What people typically do is unmarshal a more-or-less complete XML example and use it as basis.
QUESTION
The expected XML format is as per below:
...ANSWER
Answered 2017-Jul-13 at 04:34Not exactly as you want it.
You can use elements
or elementReferences
property to declare a collection property which would contain different elements as items. Something like:
QUESTION
I'm required to send an XML with the following elements:
...ANSWER
Answered 2017-Jul-07 at 06:21In your example, the prefix c
is actually bound to the namespace http://some.com/xsd/complexCondition
in this line:
Both you prefixes a
und c
are bound to non-empty namespaces within the scope of the filters
element.
So you should actually do:
{
type: 'element',
name: 'ccondition',
elementName: {
localPart: 'condition',
prefix: 'c',
namespaceURI: 'http://some.com/xsd/complexCondition'
},
typeInfo: 'DOXML.ComplexCondition'
}
I think you should be able to map to the empty namespace with namespaceURI: ''
, but this is not what you need in your case, if I see it correctly.
QUESTION
I've excluded some xml types from jaxb2 generation, due the corresponding classes already exists in Java. Generation is perfectly working and classes are founded.
When I'm trying to include the types by this tutorial, jsonix searches classes only in the package with generated jaxb2 classes. So it looks generated.entity.Position instead of entity.Position class.
...ANSWER
Answered 2017-Jan-12 at 07:33Author of Jsonix here.
Includes/excludes configuration does not what you probably think it does. It just filters types or elements you want to include in your mapping. This allows you to create smaller mappings with only stuff you need.
Still, mappings are generated per namespace/package. You can't put types from different packages to one mapping. You can, however, create a module which would contain several packages. Configuration is like:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install jsonix
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page