Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. def jsonString() {
  2. def b = new JsonBuilder()
  3. def jBuild = b {
  4. type "a"
  5. kind "b"
  6. }
  7. def j = new JsonSlurper().parseText('[{"name":"foo","attributes":[{"type":"x","kind":"x"}]}]')
  8. json << jBuild
  9. json = new JsonBuilder(json).toPrettyString()
  10. echo json
  11. }
  12.  
  13. [
  14. {
  15. "name": "foo",
  16. "attributes": [
  17. {
  18. "type": "x",
  19. "kind": "x"
  20. }
  21. ]
  22. }
  23. ]""";
  24.  
  25. {
  26. "type": "a",
  27. "kind": "b"
  28. }
  29.  
  30. [
  31. {
  32. "name": "foo",
  33. "attributes": [
  34. {
  35. "type": "x",
  36. "kind": "x"
  37. },
  38. {
  39. "type": "a",
  40. "kind": "b"
  41. }
  42. ]
  43. }
  44. ]
  45.  
  46. [
  47. {
  48. "name": "foo",
  49. "attributes": [
  50. {
  51. "type": "x",
  52. "kind": "x"
  53. }
  54. ]
  55. },
  56. {
  57. "type": "a",
  58. "kind": "b"
  59. }
  60. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement