highsource / highsource/jsonix

Allow loading mappings with unknown types, just use anyType

Open
#100 0 comments 0 reactions 1 assignee Claimed by @highsource View on GitHub
enhancement
Dominant language
JavaScript
Stars
369
Forks
85
PR merge metrics
No merged PRs in 30d

Description

At the moment Jsonix needs the complete set of mapping to initialize the `Jsonix.Context`. This may lead to large footprint of mappings you need to load - even if it is not absolutely necessary. For instance, your XML may just use only a few types from your schema and none of the dependency schemas at all. In this case you may effectively need only a subset of your mappings, not all of them. But Jsonix will fail if you don't provide all of them.

For example, with CSW 2.0.2 this is the fill set of schemas:

```
var mappings = [XLink_1_0, OWS_1_0_0, Filter_1_1_0, SMIL_2_0, SMIL_2_0_Language, GML_3_1_1, DC_1_1, DCT, CSW_2_0_2];
```

If you just need to parse capabilities, you'll only need the following schemas:

```
var mappings = [XLink_1_0, OWS_1_0_0, DC_1_1, DCT, CSW_2_0_2];
```

But at the moment you'll still need to load `Filter_1_1_0` and `SMIL_2_0` and `SMIL_2_0_Language` and `GML_3_1_1`.

The implementation should be as follows:
- A context options property like `useAnyTypeForUnknownTypes:true` or `unknownType:anyType`.
- When building the context, if an unknown type is encountered and `useAnyTypeForUnknownTypes` is `true`, log the warning and use the `anyType` type instead.
- Check that `anyType` works reasonably well for complex objects and strings.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.