Return to Snippet

Revision: 18441
at October 19, 2009 21:10 by laurenceosx


Updated Code
Jayrock supports export and importing value types (structs). Below is an example in
an interactive IronPython session where Jayrock is being used to export and import
System.Drawing.Point (struct) to and from JSON:

IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference('Jayrock.Json')
>>> from Jayrock.Json.Conversion import JsonConvert
>>> clr.AddReference('System.Drawing')
>>> from System.Drawing import Point
>>> print JsonConvert.ExportToString(Point(12,34))
{"x":12,"y":34}
>>> print JsonConvert.Import(Point, '{x:12,y:34}')
{X=12,Y=34}

Revision: 18440
at September 30, 2009 09:40 by laurenceosx


Initial Code
Jayrock supports export and importing value types (structs). Below is an example in
an interactive IronPython session where Jayrock is being used to export and import
System.Drawing.Point (struct) to and from JSON:

IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference('Jayrock.Json')
>>> from Jayrock.Json.Conversion import JsonConvert
>>> clr.AddReference('System.Drawing')
>>> from System.Drawing import Point
>>> print JsonConvert.ExportToString(Point(12,34))
{"x":12,"y":34}
>>> print JsonConvert.Import(Point, '{x:12,y:34}')
{X=12,Y=34}

I'm not sure what particular issue you are hoping to address here. It would help if
you could clarify further.

Initial URL
http://code.google.com/p/jayrock/issues/detail?id=13

Initial Description
I have not tried this out yet, but I hope it can convert IronPython types to and from json.

Initial Title
Using json with IronPython via JayRock

Initial Tags
json

Initial Language
Python