#1 Re: mORMot 1 » Mustache Logic-less templates for Delphi » 2016-01-15 08:39:56

Hello, I have a question on how to iterate objects instead of array. I used to have Mustache friendly JSON context, example:

{
  "reviews":  [
          {
                  "user_id":  1,
                  "user_name":  "u1",
                  "product_id": 1,
                  "product_name": "p1",
                  "content":  "c1",
                  "rating": 1,
                  "stars":  "★☆☆☆☆",
                  "approved": true,
                  "is_new": true
          },
          {
                  "user_id":  1,
                  "user_name":  "u1",
                  "product_id": 2,
                  "product_name": "p2",
                  "content":  "c2",
                  "rating": 4,
                  "stars":  "★★★★☆",
                  "approved": true,
                  "is_new": false
          },
          {
                  "user_id":  2,
                  "user_name":  "u2",
                  "product_id": 1,
                  "product_name": "p1",
                  "content":  "c3",
                  "rating": 3,
                  "stars":  "★★★☆☆",
                  "approved": false,
                  "is_new": false
          }
  ],
}

However, that turns out to be difficult to be used as API response as well based on the service consumer feedback, so I change it to:

{
	"result": {
		"1": {
			"product_name": "p1",
			"reviews": {
				"1": {
					"user_name": "u1",
					"content": "c1",
					"rating": 1,
					"stars": "★☆☆☆☆",
					"approved": true,
					"is_new": true
				},
				"2": {
					"user_name": "u2",
					"content": "c2",
					"rating": 3,
					"stars": "★★★☆☆",
					"approved": false,
					"is_new": false
				}
			}
		},
		"2": {
			"product_name": "p2",
			"reviews": {
				"1": {
					"user_name": "u1",
					"content": "c3",
					"rating": 4,
					"stars": "★★★★☆",
					"approved": true,
					"is_new": false
				}
			}
		}
	}
}

Essentially turning the ids into object key instead of part of an object inside an array. However, not I have problem implementing the front end because I can't (or don't know how to) iterate the objects like arrays. Is it possible to do that or is there any alternative way?

#2 Re: Free Pascal Compiler » SQLite3 Framework in FPC » 2011-04-15 01:35:30

> The documentation is available as a stand-alone document.

I've read that one, IMO those are the technical documents, mainly for maintainers and improvers to understand the architecture, but can't be used as user manual.

> But for FPC/Lazarus, I think even the core of the ORM (SynCommons/SQLite3Commons)
> won't compile as such, because of some incompatibilities

Ow... that's bad to hear sad
The ORM is a very nice feature. So could you list which projects are compatible with FPC / Lazarus? Or maybe the degree of compatibility of each project?

#3 Re: Language » TIOBE : Pascal in TOP TEN language » 2011-04-14 18:20:05

Don't forget Object Pascal in entry 21 - 50, it's in 20s the last time I saw. We're actually more than just 10th position.

#4 Free Pascal Compiler » SQLite3 Framework in FPC » 2011-04-14 18:16:24

leledumbo
Replies: 3

I've taken all Synopse Projects, but very interested in SQLite3 Framework due to its ORM and ability to export data as JSON (using these two, my web apps and services would be cleaner and better coded and organized). However, I've got a problem: where should I start learning it? There're only Delphi examples (not sure if Lazarus converter could convert them), and I don't know how to compile the documentation. I need a guide, really.

Board footer

Powered by FluxBB