forked from dizz/occi-grammar
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example showing the conversion of the OCCI text format to OCCI JSON
- Loading branch information
Showing
2 changed files
with
555 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import be.edmonds.occi.occi_http_textParser; | ||
|
||
|
||
public class occijson { | ||
|
||
/** | ||
This will output this (unformatted) JSON | ||
[ | ||
{ | ||
"category": [ | ||
{ | ||
"term": "ie", | ||
"scheme": "http://", | ||
"class": "mixin", | ||
"title": "null", | ||
"rel": "null", | ||
"location": "null", | ||
"attributes": [ | ||
null | ||
], | ||
"actions": [ | ||
null | ||
] | ||
}, | ||
{ | ||
"term": "compute", | ||
"scheme": "http://", | ||
"class": "kind", | ||
"title": "null", | ||
"rel": "null", | ||
"location": "null", | ||
"attributes": [ | ||
null | ||
], | ||
"actions": [ | ||
null | ||
] | ||
}, | ||
{ | ||
"term": "large", | ||
"scheme": "http://", | ||
"class": "mixin", | ||
"title": "null", | ||
"rel": "null", | ||
"location": "null", | ||
"attributes": [ | ||
null | ||
], | ||
"actions": [ | ||
null | ||
] | ||
}, | ||
{ | ||
"term": "ubuntu", | ||
"scheme": "http://", | ||
"class": "mixin", | ||
"title": "null", | ||
"rel": "null", | ||
"location": "null", | ||
"attributes": [ | ||
null | ||
], | ||
"actions": [ | ||
null | ||
] | ||
} | ||
], | ||
"attributes": { | ||
"my.attr": "val", | ||
"my.other": 123 | ||
} | ||
} | ||
] | ||
*/ | ||
public static void main(String[] args) { | ||
|
||
//Note that the grammar does not correct support certain values | ||
String convertMe = "Category: ie; scheme=\"http://\"; class=\"mixin\", compute; scheme=\"http://\"; class=\"kind\", large; scheme=\"http://\"; class=\"mixin\", ubuntu; scheme=\"http://\"; class=\"mixin\"" + | ||
"X-OCCI-Attribute: my.attr=\"val\", my.other=123"; | ||
|
||
try { | ||
occi_http_textParser p = occi_http_textParser.getParser(convertMe); | ||
System.out.println(p.occi_request()); | ||
|
||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
Oops, something went wrong.