Used for mapping a document (e.g. https://github.com/andersju/gdpr-xml/blob/master/consolidated/gdpr-consolidated-en.xml) to standard format
Clone repo
git clone [email protected]:slalom/standard-mapper.git
cd standard-mapper
First convert document to json
. For example, to convert gdpr-consolidated-en.xml to json use xq
(yq
https://github.com/kislyuk/yq comes with xq
):
xq '.' gdpr-consolidated-en.xml > gdpr.json
A version has been saved to assets/gdpr-en.json
Use jsonfiddle
https://github.com/go-jsonfile/jsonfiddle to generate go
types from json data
jsonfiddle j2s -i assets/gdpr-en.json
Create a file in types
package and add generated types. For gdpr
see pkg/types/gdpr.go
Create a new mapper in mappers
package. It will map from the types created in step #2 to standard types at pkg/types/standards.go. For gdpr
see pkg/mappers/gdpr-mapper.go.
Install go
brew install go
Build and run standard mapper
export GO111MODULE=on
go build && ./standard-mapper --inputFile assets/gdpr-en.json --outputFile standard.json
This will map gdpr-en.json to standard format and write to file standard.json
. It also creates the file unmarshal-debug.json
that is result of marshal'ing gdpr-en.json