Using JSON or XML as class template
(Replacing message template with parser tag)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 13: Line 13:
   </person>
   </person>
   </root>
   </root>
Right-click the class you want to use as a root for your import using, for example, [[Tajson|Tajson,]] and select "Add attributes, assoc. and classes from clipboard json or xml" - see below:
Right-click the class you want to use as a root for your import using, for example, [[Documentation:Tajson|Tajson,]] and select "Add attributes, assoc. and classes from clipboard json or xml" - see below:
[[File:2022-03-31 19h34 36 Create model from Json.png|none|thumb]]
[[File:2022-03-31 19h34 36 Create model from Json.png|none|thumb]]
This will add Root1 and Person1 classes to your model like this:
This will add Root1 and Person1 classes to your model like this:
[[File:Created model from JSON.png|none|thumb]]
[[File:Created model from JSON.png|none|thumb]]
After this, you can use JSonToObjects or [[Tajson]] to create objects from your JSON or XML.
After this, you can use [[Documentation:OCLOperators JSonToObjects|JSonToObjects]] or [[Documentation:Tajson|Tajson]] to create objects from your JSON or XML.
 
[[Category:JSON]]
[[Category:JSON]]
[[Category:XML]]
[[Category:XML]]
{{Edited|July|12|2024}}
{{Edited|July|12|2025}}

Latest revision as of 05:08, 25 February 2025

This page was created by Lars.olofsson@mdriven.net on 2022-03-31. Last edited by Stephanie@mdriven.net on 2025-02-25.

You can use an existing JSON or XML snippet as a template to create a model section you can import into.

Using the default model and the Class detail, have the following JSON snippet in the clipboard:

 <root>
  <person id='1'>
    <name>Alan</name>
    <url>http://www.google.com</url>
  </person>
  <person id='2'>
    <name>Louis</name>
    <url>http://www.yahoo.com</url>
  </person>
 </root>

Right-click the class you want to use as a root for your import using, for example, Tajson, and select "Add attributes, assoc. and classes from clipboard json or xml" - see below:

2022-03-31 19h34 36 Create model from Json.png

This will add Root1 and Person1 classes to your model like this:

Created model from JSON.png

After this, you can use JSonToObjects or Tajson to create objects from your JSON or XML.