Transforms parsed JSON objects into a uniform data structure
APACHE-2.0 License
Published by JohT about 1 year ago
Full Changelog: https://github.com/JohT/data-restructor-js/compare/v3.4.1...v3.4.2
Published by JohT over 1 year ago
Full Changelog: https://github.com/JohT/data-restructor-js/compare/v3.4.0...v3.4.1
Published by JohT almost 2 years ago
Full Changelog: https://github.com/JohT/data-restructor-js/compare/v3.3.4...v3.4.0
Published by JohT over 3 years ago
Published by JohT over 3 years ago
Published by JohT over 3 years ago
Published by JohT over 3 years ago
Published by JohT over 3 years ago
Published by JohT over 3 years ago
Published by JohT over 3 years ago
datarestructor.Restructor.processJsonUsingDescriptions(jsonData, descriptions)
is deprecated.new datarestructor.Transform(descriptions).processJson(jsonData)
instead.Published by JohT over 3 years ago
JSON.stringify(describedEntry.describedField)
can be used instead.Published by JohT over 3 years ago
Published by JohT almost 4 years ago
Since v1.2.0 templates containing variables in double curly brackets can be resolved by the function resolveTemplate(templateString)
. Now, it is not only possible to resolve the contained meta data, but also the described fields directly. Based on the JSON below, the resolver would now provide these results:
Previously (since v1.2.0), these results could only be obtained with (remains unchanged):
{
"category": "customer",
"type": "summary",
"displayName": "CustomerNumber",
"fieldName": "customerNumber",
"value": "123",
"details": [
{
"category": "customer;",
"type": "detail",
"displayName": "Name",
"fieldName": "name",
"value": "Smith"
},
{
"category": "customer",
"type": "detail",
"displayName": "Age",
"fieldName": "age",
"value": "31"
}
]
}
Published by JohT almost 4 years ago
This minor release contains the following impprovements:
PropertyStructureDescription
, it is easier to separate display related fields from e.g. the category. These fields are transferred directly into the resulting DescribedEntry
and do not affect other behavior (grouping, filtering...) in any kind.{{fieldName}}
is missing in the property pattern in "template mode", the right most part of the property name is used as field name. This corresponds to the behavior of the "equal mode". Previously this led to an error that forced the use of the "equal mode" in that case.Published by JohT almost 4 years ago
It is now possible to convert the public fields of an DescribedEntry
to JSON using its function publicFieldsJson
.
This includes all contained groups, that may contain DescribedEntry
s themselves.
Prior to this release, the following error occurred when calling JSON.stringify(describedEntry)
:
TypeError: Converting circular structure to JSON
Note:
The property isMatchingIndex
of the DescribedEntry
had been renamed to _isMatchingIndex
since it is an internal property
and should not be used outside. Since this is a "breaking change" (in theory), it lead to a new major version.
This example shows how the returned JSON looks like using parameter "space" = 2 (pretty print with 2 spaces indentation)
when the DescribedEntry
contains the group options
:
{
"category": "account",
"type": "filter",
"displayName": "Currency",
"fieldName": "currency",
"value": "eur",
"options": [
{
"category": "account;",
"type": "filter",
"displayName": "Currency",
"fieldName": "currency",
"value": "EUR"
},
{
"category": "account",
"type": "filter",
"displayName": "Currency",
"fieldName": "currency",
"value": "USD"
}
]
}
Published by JohT almost 4 years ago
It is now possible to resolve a string containing variables in double curly brackets of an DecribedEntry
using the function resolveTemplate(templateString)
.
Variables that can be used are e.g. :
"{{fieldName}}"
"{{displayName}}"
"{{value}}"
"{{index}}"
"{{index[1]}}"
Example:
var rawEntry = { name: "responses[0].hits.hits[3]._source.name", value: "Smith" };
var description = new datarestructor.PropertyStructureDescriptionBuilder().type("testtype").category("testcategory").build();
var describedEntry = new datarestructor.DescribedEntryCreator(rawEntry, description);
var resolved = describedEntry.resolveTemplate("{{displayName}}: {{value}}");
// resolved is: "Name: Smith"
Published by JohT almost 4 years ago
Published by JohT about 4 years ago