Skip to content

Conversation

@mikee47
Copy link
Owner

@mikee47 mikee47 commented Jan 9, 2025

This PR addresses issue #60 to enable variations in how JSON is generated.

An extensible ExportStream::Options structure has been added which can be manipulated via an export stream's getOption and setOption methods. This is cleaner than changing the method signatures for all createExportStream methods.

The Streaming test module demonstrates the effect of setting these options:

Streaming object export options (intarray)

RootStyle::content 13,28,39,40
RootStyle::braces [13,28,39,40]
RootStyle::name "int_array":[13,28,39,40]
RootStyle::object {"int_array":[13,28,39,40]}

With rootName override:

RootStyle::content 13,28,39,40
RootStyle::braces [13,28,39,40]
RootStyle::name "newname":[13,28,39,40]
RootStyle::object {"newname":[13,28,39,40]}

Streaming object export options (root)

RootStyle::content "int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927
RootStyle::braces {"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927}
RootStyle::name {"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927}
RootStyle::object {"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927}
// With rootName override:
RootStyle::content "int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927
RootStyle::braces {"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927}
RootStyle::name "newname":{"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927}
RootStyle::object {"newname":{"int_array":[13,28,39,40],"string_array":["a","b","c"],"object_array":[],"color":"red","simple-bool":true,"simple-string":"donkey","simple-int":100,"simple-float":3.1415927}}

@mikee47
Copy link
Owner Author

mikee47 commented Jan 9, 2025

One downside of using setOptions, etc. on ExportStream is that they're inaccessible to immediate Format::exportToStream calls. It would also be nice to include the pretty setting so applications can do everything via the generic interfaces.

@mikee47 mikee47 force-pushed the feature/export-options branch from 9b22726 to 948d1d0 Compare January 30, 2025 08:54
@mikee47 mikee47 mentioned this pull request Feb 7, 2025
@mikee47 mikee47 force-pushed the feature/export-options branch from 1ed0cf5 to 3895341 Compare February 9, 2025 10:29
@mikee47
Copy link
Owner Author

mikee47 commented Feb 11, 2025

Closing in favour of #68. This approach is too closely tied to the internal implementation using RootStyle, and the API is inconsistent.

@mikee47 mikee47 closed this Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants