Posted By

laurenceosx on 09/30/09


Tagged

json ironpython


Versions (?)

Using json with IronPython via JayRock


 / Published in: Python
 

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

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

  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}

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: laurenceosx on October 19, 2009

see:

http://stackoverflow.com/questions/799215/ironpython-json-choices

http://json.codeplex.com/

import clr clr.AddReferenceToFile("jsonnet.dll")

or

clr.AddReferenceToFileAndPath("C:\libraries\jso

You need to login to post a comment.