Using json with IronPython via JayRock


/ Published in: Python
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. Jayrock supports export and importing value types (structs). Below is an example in
  2. an interactive IronPython session where Jayrock is being used to export and import
  3. System.Drawing.Point (struct) to and from JSON:
  4.  
  5. IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053
  6. Type "help", "copyright", "credits" or "license" for more information.
  7. >>> import clr
  8. >>> clr.AddReference('Jayrock.Json')
  9. >>> from Jayrock.Json.Conversion import JsonConvert
  10. >>> clr.AddReference('System.Drawing')
  11. >>> from System.Drawing import Point
  12. >>> print JsonConvert.ExportToString(Point(12,34))
  13. {"x":12,"y":34}
  14. >>> print JsonConvert.Import(Point, '{x:12,y:34}')
  15. {X=12,Y=34}

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.