What exactly is the complete sequence b/w the spec definition and call to ionWriteJson. You have a spec with that meta. Are you trying to export the spec itself as JSON? Or some other instance data?
Nick STue 25 Feb
I have a spec defined:
AssetCore: Dict {
assetId: AssetId
usefulLife: Number <unit:"yr">
mechSystem: Ref <of:COBie_System>
usefulLifeMonths: Number <unit:"mo">
anaUOM: ANAUOMChoice
anaUOMQty: Number
partsList: List<of:Part>
childAssets: List<of:AssetId>
}
See fidelity docs for differences between JSON vs Haystack fidelity
Nick STue 25 Feb
I see what you mean with the fidelity. I think my use case made that less of a concern. The purpose of this was to get a descriptive (not necessarily full fidelity) output of the expected data for a given type. This is part of a helper document we can give to projects to guide how they compile data. The output of blah.print({json}) does really well yielding:
"usefulLife": {
"id": "ufext::AssetCore.usefulLife",
"spec": "sys::Spec",
"type": "sys::Number",
"doc": "Integer or floating point numbers annotated with an optional unit",
"val": "0",
"unit": "yr"
}
I had assumed the ioWriteJson would do the same, but I see how that could lead someone astray with the type erasure.
I can't imagine we are the only owners who are specifying to projects what data they need at turnover, so it might be useful to have some thing that exports a helpful description.
For the xeto export-json is there a way to get all inherited slots as well? Looks like it only returns the slot for that type by default.
Thank you for your help.
Brian FrankWed 26 Feb
You can use the -effective flag to dump full inheritance. Run -help to get all the options:
Usage:
xeto export-json [options] <targets>*
Arguments:
targets Libs, specs, and instances to export
Options:
-help, -? Print usage help
-all All libs installed in repo
-verbose Dump debug info as processing
-outDir <File> Output directory (generates one file per target)
-outFile <File> Output file (combine all targets in one file, default to stdout)
-effective, -e Generate inherited effective meta/slots (default is own)
Targets:
ph.points // latest version of lib
ph.points-1.0.43 // specific version of lib
ph.points::RunCmd // latest version of spec
ph.points-1.0.43::RunCmd // specific version of spec
ion.icons::apple // instance in a lib
Examples:
xeto export-json sys // latest version of lib
xeto export-json sys-1.0.3 // specific lib version
xeto export-json sys ph ph.points // multiple libs
xeto export-json ph::Rtu // one spec
xeto export-json ph -outFile foo.xeto // output to file
xeto export-json sys ph -outDir myDir // output each target to file in dir
xeto export-json -all -outDir myDir // output every lib to file in dir
xeto export-json ph::Rtu -effective // output effective meta and slots
Nick S Tue 25 Feb
When using
ioWriteJson
on a xeto spec I get an error anytime there is a unit specified. For example, this slot:throws an error:
Any advice on how to write out the JSON?
Brian Frank Tue 25 Feb
What exactly is the complete sequence b/w the spec definition and call to ionWriteJson. You have a spec with that meta. Are you trying to export the spec itself as JSON? Or some other instance data?
Nick S Tue 25 Feb
I have a spec defined:
I run:
Was expecting to write the same output to file that I see when calling
in axon shell. The print call works, the
ioWriteJson
doesn't.Brian Frank Tue 25 Feb
Ok, not sure what ioWriteJson should do in that case. Its probably not the right place for exporting specs to JSON.
But if you want to get specs in JSON, then use the command line interface like this:
See fidelity docs for differences between JSON vs Haystack fidelity
Nick S Tue 25 Feb
I see what you mean with the fidelity. I think my use case made that less of a concern. The purpose of this was to get a descriptive (not necessarily full fidelity) output of the expected data for a given type. This is part of a helper document we can give to projects to guide how they compile data. The output of
blah.print({json})
does really well yielding:I had assumed the
ioWriteJson
would do the same, but I see how that could lead someone astray with the type erasure.I can't imagine we are the only owners who are specifying to projects what data they need at turnover, so it might be useful to have some thing that exports a helpful description.
For the
xeto export-json
is there a way to get all inherited slots as well? Looks like it only returns the slot for that type by default.Thank you for your help.
Brian Frank Wed 26 Feb
You can use the
-effective
flag to dump full inheritance. Run-help
to get all the options: