Related
I have A JSON return where numbers are outputted in String.
JSON Return:
"currentClasses": [
{
"name": "CATE27600B - 3 Mobile App Programming S2#CTEC",
"grade": "100",
"weight": "6",
"credits": "1",
"Last Updated": "",
"assignments": []
},
{
"name": "CATE36400B - 1 Prac News Prod 2 S2",
"grade": "",
"weight": "5",
"credits": "1",
"Last Updated": "1/6/2022",
"assignments": [
{
"assignment": "PA Script #3",
"category": "Minor Grades",
"dateAssigned": "02/09/2022",
"dateDue": "03/04/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Social Media Posts",
"category": "Minor Grades",
"dateAssigned": "01/04/2022",
"dateDue": "03/02/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "MP3 Package/Segment #2",
"category": "Major Grades",
"dateAssigned": "01/10/2022",
"dateDue": "03/02/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Event Coverage",
"category": "Major Grades",
"dateAssigned": "01/04/2022",
"dateDue": "02/25/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "PA Script #2",
"category": "Minor Grades",
"dateAssigned": "01/24/2022",
"dateDue": "02/08/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "MP3 Package/Segment #1",
"category": "Major Grades",
"dateAssigned": "01/11/2022",
"dateDue": "02/04/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "PA Script #1",
"category": "Minor Grades",
"dateAssigned": "01/04/2022",
"dateDue": "01/21/2022",
"score": "97.00",
"totalPoints": "100.00"
},
{
"assignment": "MP3 Calendar Check",
"category": "Non-graded",
"dateAssigned": "01/04/2022",
"dateDue": "01/06/2022",
"score": "100.0",
"totalPoints": "100.00"
}
]
},
{
"name": "ELA14300B - 4 AP English Literature S2",
"grade": "85.00",
"weight": "6",
"credits": "1",
"Last Updated": "1/13/2022",
"assignments": [
{
"assignment": "Thesis Practice #1",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/13/2022",
"score": "90.00",
"totalPoints": "100.00"
},
{
"assignment": "Christmas Carol Q3 Essay",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/05/2022",
"score": "80.00",
"totalPoints": "100.00"
}
]
},
{
"name": "MTH45300B - 1 AP Calculus AB S2",
"grade": "80.80",
"weight": "6",
"credits": "1",
"Last Updated": "1/10/2022",
"assignments": [
{
"assignment": "Unit 6 Test (Integration)",
"category": "Major Grades",
"dateAssigned": "",
"dateDue": "02/08/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Delta Math Practice (Unit 6)",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "02/08/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Quiz 4 (Antiderivatives and Rules of Integration)",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/31/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Quiz 3 (FTC and Definite Integrals)",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/27/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Quiz 2 (Properties of Def. Integrals)",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/25/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Quiz 1 (Reimann Sums and Definite Integrals)",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/19/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Unit 5 Test (Analytical Applications of Derivatives)",
"category": "Major Grades",
"dateAssigned": "",
"dateDue": "01/10/2022",
"score": "78.00",
"totalPoints": "100.00"
},
{
"assignment": "Delta Math Practice (Unit 5)",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/10/2022",
"score": "85.00",
"totalPoints": "100.00"
}
]
},
{
"name": "MTH45310B - 4 AP Statistics S2",
"grade": "0.00",
"weight": "6",
"credits": "1",
"Last Updated": "",
"assignments": [
{
"assignment": "Test - 8 Confidence Intervals",
"category": "Major Grades",
"dateAssigned": "",
"dateDue": "01/26/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Skills Check - 8 Confidence Intervals",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/24/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Practice - 8.3 (canvas)",
"category": "Non-graded",
"dateAssigned": "",
"dateDue": "01/24/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Practice - 8.2 (canvas)",
"category": "Non-graded",
"dateAssigned": "",
"dateDue": "01/24/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Practice - 8.1 (canvas)",
"category": "Non-graded",
"dateAssigned": "",
"dateDue": "01/24/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Group Skills Check - 7 Sampling Distributions",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/11/2022",
"score": "",
"totalPoints": "50.00"
}
]
},
{
"name": "SCI43300B - 1 AP Environmental Science S2",
"grade": "",
"weight": "6",
"credits": "1",
"Last Updated": "",
"assignments": []
},
{
"name": "SST34300 - 4 AP Government",
"grade": "0.00",
"weight": "6",
"credits": "1",
"Last Updated": "",
"assignments": [
{
"assignment": "Midterm Exam (Units 1 & 2)",
"category": "Major Grades",
"dateAssigned": "",
"dateDue": "02/23/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Unit 2 Major Grade FRQ",
"category": "Major Grades",
"dateAssigned": "",
"dateDue": "02/16/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Unit 2 MC Quiz",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "02/14/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Unit 2 Argument FRQ Practice",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "02/11/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Unit 2 Congress FRQ Practice",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "02/04/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Unit 1 Major Grade FRQ",
"category": "Major Grades",
"dateAssigned": "",
"dateDue": "01/21/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Unit 1 MC Quiz",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/21/2022",
"score": "",
"totalPoints": "100.00"
},
{
"assignment": "Unit 1 Concept Application & Argument FRQ Practice",
"category": "Minor Grades",
"dateAssigned": "",
"dateDue": "01/14/2022",
"score": "",
"totalPoints": "100.00"
}
]
}
]
}
However I need it to be returned like this:
"currentClasses": [
[
"name": "CATE27600A - 3 Mobile App Programming S1#CTEC",
"grade": 100,
"weight": 6,
"credits": 1
],
[
"name": "CATE36400A - 1 Prac News Prod 2 S1",
"grade": 91.48,
"weight": 5,
"credits": 1
],
[
"name": "ELA14300A - 4 AP English Literature S1",
"grade": 88.13,
"weight": 6,
"credits": 1
],
[
"name": "MTH45300A - 1 AP Calculus AB S1",
"grade": 79.4,
"weight": 6,
"credits": 1
],
[
"name": "MTH45310A - 4 AP Statistics S1",
"grade": 79.48,
"weight": 6,
"credits": 1
],
[
"name": "SCI43300A - 1 AP Environmental Science S1",
"grade": 94,
"weight": 6,
"credits": 1
],
[
"name": "SST34310 - 3 AP Economics",
"grade": 93.24,
"weight": 6,
"credits": 1
]
]
I have this structure made:
// MARK: - Welcome
struct Welcome: Codable {
let currentClasses: [CurrentClass]
}
// MARK: - CurrentClass
struct CurrentClass: Codable {
let name, grade, weight, credits: String
let lastUpdated: String
let assignments: [Assignment]
enum CodingKeys: String, CodingKey {
case name, grade, weight, credits
case lastUpdated = "Last Updated"
case assignments
}
}
// MARK: - Assignment
struct Assignment: Codable {
let assignment: String
let category: Category
let dateAssigned, dateDue, score, totalPoints: String
}
enum Category: String, Codable {
case majorGrades = "Major Grades"
case minorGrades = "Minor Grades"
case nonGraded = "Non-graded"
}
I need specifically the grade, weight, and credits to be returned as a Float for all of the classes.
Your structs define those values as type String:
let name, grade, weight, credits: String
Simply change the appropriate variables to be of type Double and they will be outputted how you want.
let name: String
let grade, weight, credits: Double
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
{
"status": 200,
"message": "Success!",
"result": {
"LessonDetail": [
{
"id": 78,
"lessonjs": "<script src=\"https://learnspeakthai.com/js/lesson.js\" ></script>",
"name": "Question words #3: What?",
"code": "ST1C2L026",
"chapter_id": "12",
"sort_order": "25",
"content_top": "",
"image": "https://learnspeakthai.com/uploads/images/lesson/lesson_thumb/8b2cbbca4a711009806b915971478cb54b2ab0d1.jpg",
"show_tone_practice": "0",
"tone_practice_shown": "None",
"tone_practise_data": "",
"show_slideshow": "1",
"active": "1",
"created_at": "2011-07-28T02:51:34.000000Z",
"updated_at": "2014-10-24T20:24:17.000000Z",
"pdf": "",
"is_practise_data": 0
}
],
"SubLesson": [
{
"id": 86,
"name": "Question words 3: What?",
"show_name": "0",
"code": "ST1C2L027",
"lesson_id": "78",
"sort_order": "5",
"content_top": "‘³A-ry?’ = ‘what?’ It is always used at the end of sentence.",
"slide": [
{
"id": 321,
"sub_lesson_id": "86",
"code": "ST1C2L028",
"isaana": "³A-ry",
"thai": "อะไร",
"english": "What? ",
"english_word_order": "",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/34322cde0baa04df7ed58295863e390c7a489a98.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/ff791dbc630a4407eec2d4bdb4cbf677fac820bb.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/ed99dca146d83b40c8a91b1a2cc58844fa9d8162.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/5ca41fb350d2713194b00071fab749d36d376f8c.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:55:06.000000Z",
"updated_at": "2011-07-28T02:55:21.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 322,
"sub_lesson_id": "86",
"code": "ST1C2L029",
"isaana": "(Kun) cªheu ³a-ry?",
"thai": "คุณชื่ออะไร",
"english": "What’s your name?",
"english_word_order": "(You name what?)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/fff77db9e63b1ed203ef186c1252dee9ee47f1e6.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/85315f3e7892fdefff80dbc17a140fed7a1a0812.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/158079fe8d6aab8d95201d2c945a378b971a5e04.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/d9f7c4170a13336b95846b995add06f3537e6730.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:56:23.000000Z",
"updated_at": "2011-08-19T00:20:38.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 323,
"sub_lesson_id": "86",
"code": "ST1C2L030",
"isaana": "Cªheu B°orb",
"thai": "ชื่อบ๊อบ",
"english": "My name is Bob ",
"english_word_order": "(Name Bob)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/783d893e197d718c9d32624cf6aa6eff25113dc2.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/fae572b408441871d16d9335675f88895c533f4e.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/7b80d533c30f9d7839a1cd5f058c10092960dcf8.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/57ce04c653580cdf525af9b49d8deb19f49c9786.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:58:00.000000Z",
"updated_at": "2011-07-28T02:58:17.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 324,
"sub_lesson_id": "86",
"code": "ST1C2L031",
"isaana": "An-n°ee r§iak w§ah ³a-ry?",
"thai": "อันนี้เรียกว่าอะไร",
"english": "What’s this called?",
"english_word_order": "(This called what?)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/8244e536e5bcd1f0383b322f0df04a31926888f2.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/0c31968d79a921bf8b2810d8b05b9d01c4f6898f.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/394021ec2ff89c15a607ce3fd31ba0835115b84a.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/9034801d15fb058ea4a2bc0ba545e92cc3ec63a2.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:59:24.000000Z",
"updated_at": "2011-07-28T03:00:02.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 325,
"sub_lesson_id": "86",
"code": "ST1C2L032",
"isaana": " R§iak w§ah d§ton °my ",
"thai": " เรียกว่าต้นไม้ ",
"english": "It’s called a tree",
"english_word_order": "",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/2725e831aaf141324cc62dc61300b95dd544d487.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/b95be383542085e2c3ef1500c86c7c432c8155f9.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/e66433b0437f6b1b6d0f65b61c8b13b4e27fd57d.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/88b3abbec52de4dc667cba0b2fc4db1e1ffc42cb.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T03:01:02.000000Z",
"updated_at": "2018-05-15T09:20:24.000000Z",
"language_name": "Thai",
"language_code": "TH"
}
],
"content_bottom": "",
"image": "",
"active": "1",
"created_at": "2011-07-28T02:54:09.000000Z",
"updated_at": "2011-08-08T03:51:52.000000Z"
},
{
"id": 87,
"name": "add the polite particle ‘³na’",
"show_name": "0",
"code": "ST1C2L033",
"lesson_id": "78",
"sort_order": "10",
"content_top": "For politeness, when you use the word ‘what?’ on its own you should always add the polite particle ‘³na’. Note: This is a different polite particle than the ‘°na’ used in conjunction with ‘k°rap’ / ‘§ka’. ",
"slide": [
{
"id": 321,
"sub_lesson_id": "86",
"code": "ST1C2L028",
"isaana": "³A-ry",
"thai": "อะไร",
"english": "What? ",
"english_word_order": "",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/34322cde0baa04df7ed58295863e390c7a489a98.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/ff791dbc630a4407eec2d4bdb4cbf677fac820bb.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/ed99dca146d83b40c8a91b1a2cc58844fa9d8162.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/5ca41fb350d2713194b00071fab749d36d376f8c.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:55:06.000000Z",
"updated_at": "2011-07-28T02:55:21.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 322,
"sub_lesson_id": "86",
"code": "ST1C2L029",
"isaana": "(Kun) cªheu ³a-ry?",
"thai": "คุณชื่ออะไร",
"english": "What’s your name?",
"english_word_order": "(You name what?)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/fff77db9e63b1ed203ef186c1252dee9ee47f1e6.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/85315f3e7892fdefff80dbc17a140fed7a1a0812.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/158079fe8d6aab8d95201d2c945a378b971a5e04.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/d9f7c4170a13336b95846b995add06f3537e6730.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:56:23.000000Z",
"updated_at": "2011-08-19T00:20:38.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 323,
"sub_lesson_id": "86",
"code": "ST1C2L030",
"isaana": "Cªheu B°orb",
"thai": "ชื่อบ๊อบ",
"english": "My name is Bob ",
"english_word_order": "(Name Bob)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/783d893e197d718c9d32624cf6aa6eff25113dc2.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/fae572b408441871d16d9335675f88895c533f4e.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/7b80d533c30f9d7839a1cd5f058c10092960dcf8.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/57ce04c653580cdf525af9b49d8deb19f49c9786.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:58:00.000000Z",
"updated_at": "2011-07-28T02:58:17.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 324,
"sub_lesson_id": "86",
"code": "ST1C2L031",
"isaana": "An-n°ee r§iak w§ah ³a-ry?",
"thai": "อันนี้เรียกว่าอะไร",
"english": "What’s this called?",
"english_word_order": "(This called what?)",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/8244e536e5bcd1f0383b322f0df04a31926888f2.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/0c31968d79a921bf8b2810d8b05b9d01c4f6898f.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/394021ec2ff89c15a607ce3fd31ba0835115b84a.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/9034801d15fb058ea4a2bc0ba545e92cc3ec63a2.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T02:59:24.000000Z",
"updated_at": "2011-07-28T03:00:02.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 325,
"sub_lesson_id": "86",
"code": "ST1C2L032",
"isaana": " R§iak w§ah d§ton °my ",
"thai": " เรียกว่าต้นไม้ ",
"english": "It’s called a tree",
"english_word_order": "",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/2725e831aaf141324cc62dc61300b95dd544d487.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/b95be383542085e2c3ef1500c86c7c432c8155f9.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/e66433b0437f6b1b6d0f65b61c8b13b4e27fd57d.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/88b3abbec52de4dc667cba0b2fc4db1e1ffc42cb.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T03:01:02.000000Z",
"updated_at": "2018-05-15T09:20:24.000000Z",
"language_name": "Thai",
"language_code": "TH"
},
{
"id": 326,
"sub_lesson_id": "87",
"code": "ST1C2L033a",
"isaana": "³A-ry ³na?",
"thai": "อะไรน่ะ",
"english": "What? / pardon?",
"english_word_order": "What p.p.? ",
"language_id": "1",
"slide": "https://learnspeakthai.com/uploads/images/slide/c2e01e9bdc3455275a60fc58640fef574920931a.jpg",
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/1c9490fdc1ae25dacdecba8d5054b8bc2e116595.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/c96b08c9ee6afdd3db503abb83dbec673768284b.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/dbfede0423eb13e4fae61f0bfe3f45ef52602868.mp3",
"sort_order": null,
"pause": "0",
"active": "1",
"created_at": "2011-07-28T03:04:40.000000Z",
"updated_at": "2021-02-16T21:57:32.000000Z",
"language_name": "Thai",
"language_code": "TH"
}
],
"content_bottom": "",
"image": "",
"active": "1",
"created_at": "2011-07-28T03:03:11.000000Z",
"updated_at": "2021-02-16T21:55:34.000000Z"
}
],
"GameList": [
{
"id": 1189,
"name": "Question words #1: Matching",
"code": "ST1C2G001a",
"chapter_id": "12",
"lesson_id": "78",
"content_top": "",
"game_type": "matching",
"word_source": "selection_from_all",
"words_to_display": "10",
"sort_order": "5",
"active": "1",
"is_free": 0,
"is_subscription": 1,
"created_at": "2014-10-07T06:38:48.000000Z",
"updated_at": "2014-10-07T10:25:07.000000Z"
},
{
"id": 1190,
"name": "Question words #2: Flash card",
"code": "ST1C2G001b",
"chapter_id": "12",
"lesson_id": "78",
"content_top": "",
"game_type": "flashcard",
"word_source": "selection_from_all",
"words_to_display": "10",
"sort_order": "6",
"active": "1",
"is_free": 0,
"is_subscription": 1,
"created_at": "2014-10-07T06:57:22.000000Z",
"updated_at": "2014-10-07T10:25:38.000000Z"
}
],
"Slideshow": [
{
"id": 321,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/ff791dbc630a4407eec2d4bdb4cbf677fac820bb.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/34322cde0baa04df7ed58295863e390c7a489a98.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/ed99dca146d83b40c8a91b1a2cc58844fa9d8162.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/5ca41fb350d2713194b00071fab749d36d376f8c.mp3"
},
{
"id": 322,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/85315f3e7892fdefff80dbc17a140fed7a1a0812.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/fff77db9e63b1ed203ef186c1252dee9ee47f1e6.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/158079fe8d6aab8d95201d2c945a378b971a5e04.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/d9f7c4170a13336b95846b995add06f3537e6730.mp3"
},
{
"id": 323,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/fae572b408441871d16d9335675f88895c533f4e.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/783d893e197d718c9d32624cf6aa6eff25113dc2.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/7b80d533c30f9d7839a1cd5f058c10092960dcf8.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/57ce04c653580cdf525af9b49d8deb19f49c9786.mp3"
},
{
"id": 324,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/0c31968d79a921bf8b2810d8b05b9d01c4f6898f.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/8244e536e5bcd1f0383b322f0df04a31926888f2.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/394021ec2ff89c15a607ce3fd31ba0835115b84a.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/9034801d15fb058ea4a2bc0ba545e92cc3ec63a2.mp3"
},
{
"id": 325,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/b95be383542085e2c3ef1500c86c7c432c8155f9.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/2725e831aaf141324cc62dc61300b95dd544d487.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/e66433b0437f6b1b6d0f65b61c8b13b4e27fd57d.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/88b3abbec52de4dc667cba0b2fc4db1e1ffc42cb.mp3"
},
{
"id": 326,
"pre_slide": "https://learnspeakthai.com/uploads/images/slide/1c9490fdc1ae25dacdecba8d5054b8bc2e116595.jpg",
"slide": "https://learnspeakthai.com/uploads/images/slide/c2e01e9bdc3455275a60fc58640fef574920931a.jpg",
"audio_en": "https://learnspeakthai.com/uploads/audio/audio_en/c96b08c9ee6afdd3db503abb83dbec673768284b.mp3",
"audio_th": "https://learnspeakthai.com/uploads/audio/audio_th/dbfede0423eb13e4fae61f0bfe3f45ef52602868.mp3"
}
]
}
}
I have created model for json. I want to append value in Array of english key from json.
I am doing --
var english_Array = [[String]] ()
guard let subLesson = userResponse.result?.subLesson else {return}
for i in subLesson {
english_Array.append(i.slide?[0].english ?? "" )
}
print(english_Array)
value:
[["What?"], ["What?]]
I need -
[["What?","What’s your name?","My name is Bob","What’s this called?","It’s called a tree"],
["What?","What’s your name?","My name is Bob","What’s this called?","It’s called a tree","What? / pardon?"]]
First of all there are two values for the same key "slide". You should fix it. for now lets consider they are in an array [slide1, slide2] for the key "slides".
var english_Array = [[String]] ()
for slide in subLesson.slides {
let english = slide.map { $0.english ?? "" }
english_Array.append(english_Array)
}
this should do it.
Is it possible to use jsPDF to grab text from a HTML page and jsPDF-autotable to grab the table and to get that all inside one PDF? I have a document which has some content, and tables in the middle of the content. However, I was not able to print that document.
Sample code:
Sample code:enter code here
In the below code I am looping my Content array. Content can be of different types. For the table content am trying to use pdf.autoTable and for the text content am using pdf.text
var pdf = new jspdf('p', 'pt', 'a4');
pdf.setFontSize(18);
pdf.line(20, 25, 25, 25);
for (let i = 0; i < this.dalSectionsArray.length; i++) {
dynamicHtmlSource = dynamicHtmlSource + '<p style="text-align:left;">
<b>' + this.dalSectionsArray[i].title + '</b></p><b/>';
pdf.text(dynamicHtmlSource, 10+i, 10+i);
for (let j = 0; j < this.dalContentsArray.length; j++) {
if (this.dalSectionsArray[i].id ===
this.dalContentsArray[j].sectionView.id) {
if (this.dalContentsArray[j].subType === 'Clause') {
dynamicHtmlSource = this.getClauseData(this.dalContentsArray[j]);
pdf.text(dynamicHtmlSource,20+j,20+j);
} else if (this.dalContentsArray[j].subType === 'Block') {
dynamicHtmlSource = this.getBlockData(this.dalContentsArray[j]);
pdf.text(dynamicHtmlSource,30+j,30+j);
} else if (this.dalContentsArray[j].subType === 'Restriction') {
dynamicHtmlSource =
this.getRestrictionData(this.dalContentsArray[j]);
pdf.text(dynamicHtmlSource, 40+j, 40+j);
} else if (this.dalContentsArray[j].subType === 'Table') {
pdf.autoTable({
startY:50+j,
columnStyles: { europe: { halign: 'center' } }, // European
countries centered
body: this.dalContentsArray[j].tableValues,
columns: this.dalContentsArray[j].displayColumns
})
}
}
pdf.fromHTML('',
this.margins.left, // x coord
this.margins.top,
{
// y coord
width: this.margins.width// max width of content on PDF
}, (dispose) => {
this.headerFooterFormatting(pdf, pdf.internal.getNumberOfPages());
},
this.margins);
var iframe = document.createElement('iframe');
iframe.setAttribute('style', 'position:absolute;right:0; top:0;
bottom:0; height:100%; width:650px; padding:20px;');
document.body.appendChild(iframe);
pdf.setProperties({
title: 'jspdf-iframe',
subject: 'DAL Content',
author: 'PDFAuthor',
keywords: 'generated, javascript, web 2.0, ajax',
creator: 'ABC'
});
iframe.src = pdf.output('datauristring');
Issue is the pdf is completely messed and not printed properly. Can any
one help me in this regard.
Sample JSON:
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"sections": [
{
"title": "ABC",
"description": "",
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"_etag": "\"0d0006a2-0000-0c00-0000-5c94e5760000\"",
"partitionKey": "GGG-Section-{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"type": "Section",
"clientId": "GGG",
"createdBy": "FFFFF",
"createdDate": "2018-11-12T00:00:00",
"modifiedBy": "FFFFF",
"modifiedDate": "2018-11-12T00:00:00",
"isactive": false
},
{
"title": "DEF",
"description": "",
"order": "2",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"id": "{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
"_etag": "\"0d0004a2-0000-0c00-0000-5c94e5760000\"",
"partitionKey": "GGG-Section-{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
"type": "Section",
"clientId": "GGG",
"createdBy": "FFFFF",
"createdDate": "2018-11-12T00:00:00",
"modifiedBy": "FFFFF",
"modifiedDate": "2018-11-12T00:00:00",
"isactive": false
},
{
"title": "GHI",
"description": "",
"order": "3",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"_etag": "\"0d00faa1-0000-0c00-0000-5c94e5750000\"",
"partitionKey": "GGG-Section-{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"type": "Section",
"clientId": "GGG",
"createdBy": "FFFFF",
"createdDate": "2018-11-12T00:00:00",
"modifiedBy": "FFFFF",
"modifiedDate": "2018-11-12T00:00:00",
"isactive": false
}
],
"contents": [
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{a351366f-bf4b-44e0-94ff-a81be899ec3a}-{1}",
"subType": "Table",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "AAA",
"description": "",
"order": "4"
},
"title": "PL",
"description": "",
"order": "3",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [ "N", "M", "O", "P" ],
"tableValues": [
{
"N": "Level 21",
"M": "22",
"O": "",
"P": "",
"isRowEditable": false
},
{
"id": "6cb79b9f-2ef2-4d3a-b6c4-7d84dd61aaf7",
"isDeleted": true,
"N": "KKKKKKK",
"M": "GBP 20M",
"O": "",
"isRowEditable": false
},
{
"id": "c83caf0b-8f00-4dc8-bf35-473bda398937",
"isDeleted": true,
"N": "EP",
"M": "GBP 15M",
"O": "",
"isRowEditable": false
}
],
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{16a3fb1e-f7fa-4dfe-a4d3-c51b56c8dbee-uw}-{1}",
"_etag": "\"0d00a0ca-0000-0c00-0000-5c94ef3f0000\"",
"partitionKey": "GGG-CCCCOOOOO-{16a3fb1e-f7fa-4dfe-a4d3-c51b56c8dbee-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{2b498850-8f11-475d-b170-5705d05c4bf1}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"title": "LLL",
"description": "",
"order": "3"
},
"title": "kkkkk",
"Description": [
{
"type": "label",
"value": "<br/>Some sample text here"
}
],
"order": "6",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{6193cef1-2fe5-47c2-8367-0650ab66caf3-uw}-{1}",
"_etag": "\"0d00a5ca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{6193cef1-2fe5-47c2-8367-0650ab66caf3-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{d6793120-5e5b-40ec-a1ea-e82e7bdc9d1a}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "UT",
"description": "Sample Text",
"order": "4"
},
"title": "PR",
"Description": [
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "any one programme/risk</li><li>a maximum premium of "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "<br/>SSample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ".Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ", on Lloyd's paper, in respect of Canadian domiciled Property risks<br/>Your authority for Health extends to unlimited Healthcare where required by statute<br/>You may accept up to "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ", on Lloyd's paper, in respect of declarations under the Coast P&I Facility<br/>You may accept up to "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ", on Lloyd's paper, in respect of combined primary and excess grounding liability<br/>"
}
],
"order": "6",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{22505164-4d56-493e-8df2-b1bb53ab419a-uw}-{1}",
"_etag": "\"0d00acca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{22505164-4d56-493e-8df2-b1bb53ab419a-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{ac949799-60c7-4f85-840f-f30203c5ee43}-{1}",
"subType": "Block",
"sectionView": {
"id": "{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
"title": "GR",
"description": "",
"order": "2"
},
"title": "",
"description": "Sample",
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{8652fedc-0d7c-48d8-bc3f-577294551671-uw}-{1}",
"_etag": "\"0d00baca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{8652fedc-0d7c-48d8-bc3f-577294551671-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{522f1248-0882-4348-9bba-59c056c816c8}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"title": "LLL",
"description": "",
"order": "3"
},
"title": "UP",
"Description": [
{
"type": "label",
"value": "Sample"
}
],
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{944eae3d-fa0f-4b0e-9c66-3499a16fc2fd-uw}-{1}",
"_etag": "\"0d00bfca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{944eae3d-fa0f-4b0e-9c66-3499a16fc2fd-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{6c6a3c80-3536-4c51-8ccf-fcdc16d94090}-{1}",
"subType": "Table",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "PT",
"description": "",
"order": "4",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [ ".", "KKKKKKK", "EP", "P" ],
"tableValues": [
{
".": "Level 11",
"KKKKKKK": "",
"EP": "Level 21",
"P": "",
"isRowEditable": false
},
{
".": "Asbestos - other than licensed removers",
"KKKKKKK": "GBP 5M",
"EP": ".",
"isRowEditable": false
},
{
".": "Auto manufacturing - safety critical components",
"KKKKKKK": "GBP 10M",
"EP": ".",
"isRowEditable": false
},
{
".": "Rail - contracting companies",
"KKKKKKK": "GBP 5M",
"EP": ".",
"isRowEditable": false
},
{
".": "Asbestos - other than licensed removers",
"KKKKKKK": ".",
"EP": "GBP 10M",
"isRowEditable": false
},
{
".": "Rail - contracting companies",
"KKKKKKK": ".",
"EP": "GBP 10M",
"isRowEditable": false
}
],
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": "."
}
],
"id": "{91de8a0b-4156-4121-be05-844b03928c29-uw}-{1}",
"_etag": "\"0d00c5ca-0000-0c00-0000-5c94ef410000\"",
"partitionKey": "GGG-CCCCOOOOO-{91de8a0b-4156-4121-be05-844b03928c29-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{92860693-e038-4a58-814c-6a74d59e7cce}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "",
"Description": [
{
"type": "label",
"value": "Sample"
}
],
"order": "9",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{af17341e-a88c-4564-8296-c513e3708af2-uw-per}-{1}",
"_etag": "\"0d00e3ca-0000-0c00-0000-5c94ef420000\"",
"partitionKey": "GGG-CCCCOOOOO-{af17341e-a88c-4564-8296-c513e3708af2-uw-per}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{92860693-e038-4a58-814c-6a74d59e7cce}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "PL",
"Description": [
{
"type": "label",
"value": "Sample"
}
],
"order": "7",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{af17341e-a88c-4564-8296-c513e3708af2-uw}-{1}",
"_etag": "\"0d00e8ca-0000-0c00-0000-5c94ef420000\"",
"partitionKey": "GGG-CCCCOOOOO-{af17341e-a88c-4564-8296-c513e3708af2-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{92c5bd05-c8a2-45c1-a1e9-fd3f78c705ab}-{1}",
"subType": "Table",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "KKPKPKPK PP",
"description": "",
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [ "N", "kkk", "LPLPLPL", "Ccy", "M", "LTLT", "P" ],
"tableValues": [
{
"N": "Level 11",
"kkk": "",
"LPLPLPL": "",
"Ccy": "",
"M": "",
"LTLT": "",
"P": "",
"isRowEditable": false
},
{
"N": "Level 11",
"kkk": "",
"LPLPLPL": "",
"Ccy": "",
"M": "11",
"LTLT": "",
"P": "",
"isRowEditable": false
},
{
"N": "QQQl",
"kkk": "QQQQ",
"LPLPLPL": "DDDD",
"Ccy": "GBP",
"M": "10M",
"LTLT": "Any one vessel",
"isRowEditable": false
},
{
"N": "Marine Cargo",
"kkk": "QIEL",
"LPLPLPL": "Lineslip and other non-coverholder facilities",
"Ccy": "GBP",
"M": "5M",
"LTLT": "Any one event",
"isRowEditable": false
},
{
"N": "KKKK",
"kkk": "PPPP",
"LPLPLPL": "DDDD",
"Ccy": "GBP",
"M": "20M",
"LTLT": "Any one vessel",
"isRowEditable": false
}
],
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{d036bc60-db2d-4c93-86ff-981a62e207ca-uw}-{1}",
"_etag": "\"0d00eacb-0000-0c00-0000-5c94ef530000\"",
"partitionKey": "GGG-CCCCOOOOO-{d036bc60-db2d-4c93-86ff-981a62e207ca-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{bf1f6e82-6afd-4837-81ab-acabc665da14}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"title": "LLL",
"description": "",
"order": "3"
},
"title": "klklkl",
"Description": [
{
"type": "label",
"value": "sAMPLE tEXT"
}
],
"order": "4",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{QQ-851f96e7-542f-4a57-a0b1-35feb4698f5e-uw}-{1}",
"_etag": "\"0d0062cc-0000-0c00-0000-5c94ef5a0000\"",
"partitionKey": "GGG-CCCCOOOOO-{QQ-851f96e7-542f-4a57-a0b1-35feb4698f5e-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
}
]
}
getClauseData(dalContentdata) {
let dynamicClauseHtmlSource = '<h4>' + dalContentdata.title + '</h4>';
dynamicClauseHtmlSource = dynamicClauseHtmlSource + '<p></p>';
dynamicClauseHtmlSource = dynamicClauseHtmlSource + + '<p style="text-align:justify;line-height:0.3em">' + dalContentdata.description + '</p>';
dynamicClauseHtmlSource = this.brToNewLine(dynamicClauseHtmlSource);
return dynamicClauseHtmlSource;
}
getBlockData(dalContentdata) {
let dynamicBlockHtmlSource = '<h4>' + dalContentdata.title + '</h4>';
dynamicBlockHtmlSource = dynamicBlockHtmlSource + '<p></p>';
dynamicBlockHtmlSource = dynamicBlockHtmlSource + dalContentdata.description;
dynamicBlockHtmlSource = this.brToNewLine(dynamicBlockHtmlSource);
return dynamicBlockHtmlSource;
}
getTableData(dalContentdata) {
let tableSource = "<table>";
tableSource = tableSource + "<tr>";
for (var k = 0; k < dalContentdata.displayColumns.length; k++) {
tableSource = tableSource + "<th style='word-wrap: break-word'>" + dalContentdata.displayColumns[k] + "</th>";
}
tableSource = tableSource + "</tr>";
for (var j = 0; j < dalContentdata.tableValues.length; j++) {
tableSource = tableSource + "<tr>";
for (var k = 0; k < dalContentdata.displayColumns.length; k++) {
tableSource = tableSource + "<td style='word-wrap: break-word'>" + dalContentdata.tableValues[0][dalContentdata.displayColumns[k]] + "</td>";
}
tableSource = tableSource + "</tr>";
}
tableSource = tableSource + "</table>";
return tableSource;
}
brToNewLine(str) {
return str.replace(/<br ?\/?>/g, "\n");
}
This is the json I got from server I tried to create a data model for this json but didn't get in to success because of nested arrays. can anyone please help in creating data model for this jsonfile in swift. if you need I can provide the the data model I created for this json but that is not working
{
"result": [
{
"loo_id": null,
"loo_name": null,
"loo_address": null,
"loo_image": null,
"price": null,
"loo_location": null,
"type": null,
"category": [
{
"category_id": "1",
"category_name": "Hotel",
"cat_enable_image": "****images/category/hotel_clr.png",
"cat_disable_image": "****images/category/hotel_gry.png",
"status": "0"
},
{
"category_id": "5",
"category_name": "Shopping Mall",
"cat_enable_image": "****images/category/shopping_mall_clr.png",
"cat_disable_image": "****images/category/shopping_mall_gry.png",
"status": "0"
}
],
"days": null,
"timings": null,
"facilities": [
{
"facility_category_id": "1",
"facility_category_name": "Male",
"facility_category_enable_image": "****images/facility_category/male_clr.png",
"facility_category_disable_image": "****images/facility_category/male_gry.png",
"status": "0",
"facility": [
{
"facility_id": "1",
"facility_name": "Toiletten",
"enable_image": "****images/facilities/toilet_color.png",
"disable_image": "****images/facilities/toilet_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "2",
"facility_name": "Lavatory",
"enable_image": "****images/facilities/lavatory_color.png",
"disable_image": "****images/facilities/lavatory_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "3",
"facility_name": "Urinals",
"enable_image": "****images/facilities/urinals_color.png",
"disable_image": "****images/facilities/urinals_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "4",
"facility_name": "Shower",
"enable_image": "****images/facilities/shower_color.png",
"disable_image": "****images/facilities/shower_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "5",
"facility_name": "Standing Toilet",
"enable_image": "****images/facilities/standing_toilet_color.png",
"disable_image": "****images/facilities/standing_toilet_grey.png",
"count": "0",
"status": "0"
}
]
},
{
"facility_category_id": "4",
"facility_category_name": "Wheelchair",
"facility_category_enable_image": "****images/facility_category/1771138800.png",
"facility_category_disable_image": "****images/facility_category/1790222751.png",
"status": "0",
"facility": [
{
"facility_id": "12",
"facility_name": "Toiletten",
"enable_image": "****images/facilities/toilet_color.png",
"disable_image": "****images/facilities/toilet_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "13",
"facility_name": "Lavatory",
"enable_image": "****images/facilities/lavatory_color.png",
"disable_image": "****images/facilities/lavatory_grey.png",
"count": "0",
"status": "0"
},
{
"facility_id": "14",
"facility_name": "Shower",
"enable_image": "****images/facilities/shower_color.png",
"disable_image": "****images/facilities/shower_grey.png",
"count": "0",
"status": "0"
}
]
}
],
"accessbility": [
{
"accessbility_id": "1",
"accessbility_name": "Wheelchair",
"accessbility_enable_image": "****images/accessbility/wheelchair_clr.png",
"accessbility_disable_image": "****images/accessbility/wheelchair_gry.png",
"status": "0"
},
{
"accessbility_id": "2",
"accessbility_name": "Car Access",
"accessbility_enable_image": "****images/accessbility/car_access_clr.png",
"accessbility_disable_image": "****images/accessbility/car_access_gry.png",
"status": "0"
}
],
"terms_conditions": null
}
]
}
I want to create invoice in my Quickbooks account through API from my rails application, but it requires to add customer and item before creating invoice. But I can't get the idea how to add customer and items through API. Can you suggest me???
Thanks.
Start here:
https://developer.intuit.com/
Follow the docs (https://developer.intuit.com/docs/0100_accounting) and implement OAuth to connect to QuickBooks Online.
Create customers by HTTP POSTing a JSON request to QuickBooks Online:
https://developer.intuit.com/docs/api/accounting/Customer
The JSON request will look something like this:
{
"BillAddr": {
"Line1": "123 Main Street",
"City": "Mountain View",
"Country": "USA",
"CountrySubDivisionCode": "CA",
"PostalCode": "94042"
},
"Notes": "Here are other details.",
"Title": "Mr",
"GivenName": "James",
"MiddleName": "B",
"FamilyName": "King",
"Suffix": "Jr",
"FullyQualifiedName": "King Groceries",
"CompanyName": "King Groceries",
"DisplayName": "King's Groceries",
"PrimaryPhone": {
"FreeFormNumber": "(555) 555-5555"
},
"PrimaryEmailAddr": {
"Address": "jdrew#myemail.com"
}
}
You'll get back something like this:
{
"Customer": {
"Taxable": true,
"BillAddr": {
"Id": "112",
"Line1": "123 Main Street",
"City": "Mountain View",
"Country": "USA",
"CountrySubDivisionCode": "CA",
"PostalCode": "94042"
},
"Notes": "Here are other details.",
"Job": false,
"BillWithParent": false,
"Balance": 0,
"BalanceWithJobs": 0,
"CurrencyRef": {
"value": "USD",
"name": "United States Dollar"
},
"PreferredDeliveryMethod": "Print",
"domain": "QBO",
"sparse": false,
"Id": "67",
"SyncToken": "0",
"MetaData": {
"CreateTime": "2015-07-23T10:58:12-07:00",
"LastUpdatedTime": "2015-07-23T10:58:12-07:00"
},
"Title": "Mr",
"GivenName": "James",
"MiddleName": "B",
"FamilyName": "King",
"Suffix": "Jr",
"FullyQualifiedName": "King's Groceries",
"CompanyName": "King Groceries",
"DisplayName": "King's Groceries",
"PrintOnCheckName": "King Groceries",
"Active": true,
"PrimaryPhone": {
"FreeFormNumber": "(555) 555-5555"
},
"PrimaryEmailAddr": {
"Address": "jdrew#myemail.com"
},
"DefaultTaxCodeRef": {
"value": "2"
}
},
"time": "2015-07-23T10:58:12.099-07:00"
}
Make sure you save that Id attribute, you'll need that later.
The process for creating Items is similar. Docs:
https://developer.intuit.com/docs/api/accounting/Item
Everything is just standard OAuth requests. Go grab an OAuth library for Rails and you should be all set.