discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: json

TP
Torsten Paul
Thu, Jan 12, 2023 5:57 PM

On 12.01.23 18:39, Trevor Orr via Discuss wrote:

The latest dev snap shot support loading json files which is
really cool, is there a way to generate json objects in OpenSCAD?

If you mean generating the same data structure in the script
itself without using import() then the answer is no (for the
normal releases and dev snapshots), and yes via the features
cooking in

https://github.com/openscad/openscad/pull/4478

ciao,
Torsten.

On 12.01.23 18:39, Trevor Orr via Discuss wrote: > The latest dev snap shot support loading json files which is > really cool, is there a way to generate json objects in OpenSCAD? If you mean generating the same data structure in the script itself without using import() then the answer is no (for the normal releases and dev snapshots), and yes via the features cooking in https://github.com/openscad/openscad/pull/4478 ciao, Torsten.
JB
Jordan Brown
Thu, Jan 12, 2023 6:31 PM

On 1/12/2023 9:57 AM, Torsten Paul wrote:

On 12.01.23 18:39, Trevor Orr via Discuss wrote:

The latest dev snap shot support loading json files which is
really cool, is there a way to generate json objects in OpenSCAD?

If you mean generating the same data structure in the script
itself without using import() then the answer is no (for the
normal releases and dev snapshots), and yes via the features
cooking in

https://github.com/openscad/openscad/pull/4478

And if you mean generating a JSON file, today you can always use echo(),
but you'd have to either cut-and-paste from the GUI or lightly filter
output from the CLI.

With 4478, echo(obj) may come close to emitting JSON text.  There are
two reasons why it wouldn't:

  • It primarily emits OpenSCAD source, and it's unclear as yet whether
    OpenSCAD will look like JSON or not.
  • JSON requires that all keys be quoted, and it doesn't quote keys
    that OpenSCAD/JavaScript doesn't require be quoted.

Perhaps 4478 should gain a json() function that converts an OpenSCAD
object into JSON text.

On 1/12/2023 9:57 AM, Torsten Paul wrote: > On 12.01.23 18:39, Trevor Orr via Discuss wrote: > > The latest dev snap shot support loading json files which is > > really cool, is there a way to generate json objects in OpenSCAD? > > If you mean generating the same data structure in the script > itself without using import() then the answer is no (for the > normal releases and dev snapshots), and yes via the features > cooking in > > https://github.com/openscad/openscad/pull/4478 And if you mean generating a JSON file, today you can always use echo(), but you'd have to either cut-and-paste from the GUI or lightly filter output from the CLI. With 4478, echo(obj) may come close to emitting JSON text.  There are two reasons why it wouldn't: * It primarily emits OpenSCAD source, and it's unclear as yet whether OpenSCAD will look like JSON or not. * JSON requires that all keys be quoted, and it doesn't quote keys that OpenSCAD/JavaScript doesn't require be quoted. Perhaps 4478 should gain a json() function that converts an OpenSCAD object into JSON text.
TO
Trevor Orr
Thu, Jan 12, 2023 8:27 PM

Cool thanks, that will be a great thing to have.

On Thu, Jan 12, 2023 at 9:57 AM Torsten Paul Torsten.Paul@gmx.de wrote:

On 12.01.23 18:39, Trevor Orr via Discuss wrote:

The latest dev snap shot support loading json files which is
really cool, is there a way to generate json objects in OpenSCAD?

If you mean generating the same data structure in the script
itself without using import() then the answer is no (for the
normal releases and dev snapshots), and yes via the features
cooking in

https://github.com/openscad/openscad/pull/4478

ciao,
Torsten.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Cool thanks, that will be a great thing to have. On Thu, Jan 12, 2023 at 9:57 AM Torsten Paul <Torsten.Paul@gmx.de> wrote: > On 12.01.23 18:39, Trevor Orr via Discuss wrote: > > The latest dev snap shot support loading json files which is > > really cool, is there a way to generate json objects in OpenSCAD? > > If you mean generating the same data structure in the script > itself without using import() then the answer is no (for the > normal releases and dev snapshots), and yes via the features > cooking in > > https://github.com/openscad/openscad/pull/4478 > > ciao, > Torsten. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
GS
Guenther Sohler
Thu, Jan 12, 2023 8:50 PM

Hi Trevor,
I am Just curious,
What ist your use Case when you Use openscad to Import and Export json
Files. Can you Detail?

Trevor Orr fractorr@gmail.com schrieb am Do., 12. Jän. 2023, 21:27:

Cool thanks, that will be a great thing to have.

On Thu, Jan 12, 2023 at 9:57 AM Torsten Paul Torsten.Paul@gmx.de wrote:

On 12.01.23 18:39, Trevor Orr via Discuss wrote:

The latest dev snap shot support loading json files which is
really cool, is there a way to generate json objects in OpenSCAD?

If you mean generating the same data structure in the script
itself without using import() then the answer is no (for the
normal releases and dev snapshots), and yes via the features
cooking in

https://github.com/openscad/openscad/pull/4478

ciao,
Torsten.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Hi Trevor, I am Just curious, What ist your use Case when you Use openscad to Import and Export json Files. Can you Detail? Trevor Orr <fractorr@gmail.com> schrieb am Do., 12. Jän. 2023, 21:27: > Cool thanks, that will be a great thing to have. > > On Thu, Jan 12, 2023 at 9:57 AM Torsten Paul <Torsten.Paul@gmx.de> wrote: > >> On 12.01.23 18:39, Trevor Orr via Discuss wrote: >> > The latest dev snap shot support loading json files which is >> > really cool, is there a way to generate json objects in OpenSCAD? >> >> If you mean generating the same data structure in the script >> itself without using import() then the answer is no (for the >> normal releases and dev snapshots), and yes via the features >> cooking in >> >> https://github.com/openscad/openscad/pull/4478 >> >> ciao, >> Torsten. >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >