Skip to content

Commit

Permalink
docs: format JSON code blocks as jsonc (parse-community#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMartinR authored Jul 2, 2022
1 parent 86d16c0 commit bda8566
Show file tree
Hide file tree
Showing 37 changed files with 246 additions and 180 deletions.
12 changes: 9 additions & 3 deletions _includes/android/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ gameScore.saveInBackground();

After this code runs, you will probably be wondering if anything really happened. To make sure the data was saved, you can look at the Data Browser in your app on Parse. You should see something like this:

```javascript
objectId: "xWMyZ4YEGZ", score: 1337, playerName: "Sean Plott", cheatMode: false,
createdAt:"2022-01-01T12:23:45.678Z", updatedAt:"2022-01-01T12:23:45.678Z"
```jsonc
{
"objectId": "xWMyZ4YEGZ",
"score": 1337,
"playerName": "Sean Plott",
"cheatMode": false,
"createdAt":"2022-01-01T12:23:45.678Z",
"updatedAt":"2022-01-01T12:23:45.678Z"
}
```

There are two things to note here. You didn't have to configure or set up a new Class called `GameScore` before running this code. Your Parse app lazily creates this Class for you when it first encounters it.
Expand Down
11 changes: 9 additions & 2 deletions _includes/arduino/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ response.close(); // Free the resource

After this code runs, you will probably be wondering if anything really happened. To make sure the data was saved, you can look at the Data Browser in your app on Parse. You should see something like this:

```javascript
objectId: "xWMyZ4YEGZ", temperature: 175.0, leverDown: true, createdAt: "2022-01-01T12:23:45.678Z", updatedAt: "2022-01-01T12:23:45.678Z"
```jsonc
{
"objectId": "xWMyZ4YEGZ",
"score": 1337,
"playerName": "Sean Plott",
"cheatMode": false,
"createdAt":"2022-01-01T12:23:45.678Z",
"updatedAt":"2022-01-01T12:23:45.678Z"
}
```

There are two things to note here. You didn't have to configure or set up a new Class called `Temperature` before running this code. Your Parse app lazily creates this Class for you when it first encounters it.
Expand Down
22 changes: 11 additions & 11 deletions _includes/cloudcode/cloud-code-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ end

Here's an example of the JSON data that would be sent in the request to this webhook:

```json
```jsonc
// Sent to webhook
{
"master": false,
Expand All @@ -225,14 +225,14 @@ Here's an example of the JSON data that would be sent in the request to this web

This response would indicate a success in the webhook:

```json
```jsonc
// Returned from the webhook on success
{ "success": "Hello World!" }
```

This response would indicate an error in the webhook:

```json
```jsonc
// Returned from the webhook on error
{ "error": "Error message >:(" }
```
Expand Down Expand Up @@ -275,7 +275,7 @@ end

Here's an example of the JSON data that would be sent in the request to this webhook:

```json
```jsonc
// Sent to webhook
{
"master": true,
Expand All @@ -287,7 +287,7 @@ Here's an example of the JSON data that would be sent in the request to this web

This response would indicate a success in the webhook:

```json
```jsonc
// Returned from the webhook on success
{ "success": "User billed!" }
```
Expand All @@ -310,7 +310,7 @@ For triggers, the following parameters are sent to your webhook.

To respond to a `beforeSave` request, send a JSON object with the key `error` or `success` set. This is the same as for Cloud functions, but there's an extra capability with `beforeSave` triggers. By returning an error, you will cancel the save request and the object will not be stored on Parse. You can also return a JSON object in this following format to override the values that will be saved for the object:

```json
```jsonc
{
"className": "AwesomeClass",
"existingColumn": "sneakyChange",
Expand Down Expand Up @@ -348,7 +348,7 @@ end

Here's an example of the JSON data that would be sent in the request to this webhook:

```json
```jsonc
// Sent to webhook
{
"master": false,
Expand Down Expand Up @@ -419,7 +419,7 @@ end

Here's an example of the JSON data that would be sent in the request to this webhook:

```json
```jsonc
// Sent to webhook
{
"master": false,
Expand Down Expand Up @@ -485,7 +485,7 @@ end

Here's an example of the JSON data that would be sent in the request to this webhook:

```json
```jsonc
// Sent to webhook
{
"master": false,
Expand All @@ -509,7 +509,7 @@ Here's an example of the JSON data that would be sent in the request to this web

This response would indicate a success in the webhook:

```json
```jsonc
// Returned from the webhook on success
{ "success": true }
```
Expand Down Expand Up @@ -554,7 +554,7 @@ end

Here's an example of the JSON data that would be sent in the request to this webhook:

```json
```jsonc
// Sent to webhook
{
"master": false,
Expand Down
6 changes: 3 additions & 3 deletions _includes/cloudcode/cloud-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Let's look at a slightly more complex example where Cloud Code is useful. One reason to do computation in the cloud is so that you don't have to send a huge list of objects down to a device if you only want a little bit of information. For example, let's say you're writing an app that lets people review movies. A single `Review` object could look like:

```json
```jsonc
{
"movie": "The Matrix",
"stars": 5,
Expand Down Expand Up @@ -112,13 +112,13 @@ In general, two arguments will be passed into cloud functions:

If the function is successful, the response in the client looks like:

```json
```jsonc
{ "result": 4.8 }
```

If there is an error, the response in the client looks like:

```json
```jsonc
{
"code": 141,
"error": "movie lookup failed"
Expand Down
4 changes: 2 additions & 2 deletions _includes/common/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ You may import data into your Parse app by using CSV or JSON files. To create a

The JSON format is an array of objects in our REST format or a JSON object with a `results` that contains an array of objects. It must adhere to the [JSON standard](http://json.org/). A file containing regular objects could look like:

```js
```jsonc
{ "results": [
{
"score": 1337,
Expand All @@ -63,7 +63,7 @@ In addition to the exposed fields, objects in the Parse User class can also have

A file containing a `User` object could look like:

```js
```jsonc
{ "results":
[{
"username": "cooldude",
Expand Down
6 changes: 3 additions & 3 deletions _includes/common/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ All this is just the beginning. Applications can enforce all sorts of complex ac

For the curious, here's the format for an ACL that restricts read and write permissions to the owner (whose `objectId` is identified by `"aSaMpLeUsErId"`) and enables other users to read the object:

```json
```jsonc
{
"*": { "read":true },
"aSaMpLeUsErId": { "read" :true, "write": true }
Expand All @@ -398,7 +398,7 @@ For the curious, here's the format for an ACL that restricts read and write perm

And here's another example of the format of an ACL that uses a Role:

```json
```jsonc
{
"role:RoleName": { "read": true },
"aSaMpLeUsErId": { "read": true, "write": true }
Expand All @@ -413,7 +413,7 @@ Given that objects often already have pointers to the user(s) that should have p

Pointer permissions are like virtual ACLs. They don't appear in the ACL column, but if you are familiar with how ACLs work, you can think of them like ACLs. In the above example with the `sender` and `receiver`, each object will act as if it has an ACL of:

```json
```jsonc
{
"<SENDER_USER_ID>": {
"read": true,
Expand Down
12 changes: 9 additions & 3 deletions _includes/dotnet/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ await gameScore.SaveAsync();

After this code runs, you will probably be wondering if anything really happened. To make sure the data was saved, you can look at the Data Browser in your app on Parse. You should see something like this:

```javascript
objectId: "xWMyZ4YEGZ", score: 1337, playerName: "Sean Plott", cheatMode: false,
createdAt:"2022-01-01T12:23:45.678Z", updatedAt:"2022-01-01T12:23:45.678Z"
```jsonc
{
"objectId": "xWMyZ4YEGZ",
"score": 1337,
"playerName": "Sean Plott",
"cheatMode": false,
"createdAt":"2022-01-01T12:23:45.678Z",
"updatedAt":"2022-01-01T12:23:45.678Z"
}
```

There are two things to note here. You didn't have to configure or set up a new Class called `GameScore` before running this code. Your Parse app lazily creates this Class for you when it first encounters it.
Expand Down
4 changes: 2 additions & 2 deletions _includes/graphql/classes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Classes

Since your application does not have a schema yet, you can use the `createClass` mutation to create your first class through the GraphQL API. Run the following:
```js
```jsonc
// Header
{
"X-Parse-Application-Id": "APPLICATION_ID",
Expand Down Expand Up @@ -34,7 +34,7 @@ mutation createGameScoreClass {
}
}
```
```js
```jsonc
// Response
{
"data": {
Expand Down
24 changes: 12 additions & 12 deletions _includes/graphql/customisation.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ By default, all of your Parse classes, including the defaults such as `Parse.Use

In the following example, we limit our GraphQL schema to only expose the default `_User` class, along with a few custom classes:

```javascript
```jsonc
{
"enabledForClasses": ["_User", "Book", "Review", "Comment"],
"disabledForClasses": null
Expand All @@ -133,7 +133,7 @@ By default, we enrich the schema by generating a number of [Input Types](https:/

In the following example, we have a custom class called `Review` where the fields `rating` and `body` are allowed on the `create` mutation, and the field `numberOfLikes` on the `update` mutation:

```javascript
```jsonc
{
"classConfigs": [
{
Expand All @@ -151,7 +151,7 @@ In the following example, we have a custom class called `Review` where the field

You may decide to restrict which fields can be resolved when getting or finding records from a given class, for example, if you have a class called `Video` which includes a sensitive field `dmcaFlags`, you can hide this field by explicitly stating the fields that can be resolved:

```javascript
```jsonc
{
"classConfigs": [
{
Expand All @@ -169,7 +169,7 @@ In production-grade environments where performance optimisation is critical, com

In the following example, we set the fields `name` and `age` as the only two that can be used to filter the `_User` class, and defining the `createdAt` and `age` fields the only sortable field whilst disabling the ascending direction on the `createdAt` field:

```javascript
```jsonc
{
"classConfigs": [
{
Expand Down Expand Up @@ -199,7 +199,7 @@ In the following example, we set the fields `name` and `age` as the only two tha
By default, the schema exposes a `get` and `find` operation for each class, for example, `get_User` and `find_User`. You can disable either of these for any class in your schema, like so:


```javascript
```jsonc
{
"classConfigs": [
{
Expand All @@ -222,7 +222,7 @@ By default, the schema exposes a `get` and `find` operation for each class, for

By default, generated query names use pluralized version of `className`. You can override this behaviour with `getAlias`/`findAlias`. This is useful when your collection is named in plural or when singular/plural forms are same e.g. `Data`:

```javascript
```jsonc
{
"classConfigs": [
{
Expand All @@ -246,7 +246,7 @@ By default, generated query names use pluralized version of `className`. You can
By default, the schema exposes a `create`, `update` and `delete` operation for each class, for example, `create_User`, `update_User` and `delete_User`. You can disable any of these mutations for any class in your schema, like so:


```javascript
```jsonc
{
"classConfigs": [
{
Expand All @@ -273,7 +273,7 @@ By default, the schema exposes a `create`, `update` and `delete` operation for e

You can optionally override the default generated mutation names with aliases:

```javascript
```jsonc
{
"classConfigs": [
{
Expand Down Expand Up @@ -326,7 +326,7 @@ extend type Query {
Parse.Cloud.define("hello", () => "Hello, world!");
```

```js
```jsonc
// Header
{
"X-Parse-Application-Id": "APPLICATION_ID",
Expand All @@ -342,7 +342,7 @@ query hello {

The code above should resolve to this:

```js
```jsonc
// Response
{
"data": {
Expand Down Expand Up @@ -418,7 +418,7 @@ Parse.Cloud.define("addToCart", async (req) => {
});
```

```js
```jsonc
// Header
{
"X-Parse-Application-Id": "APPLICATION_ID",
Expand All @@ -437,7 +437,7 @@ mutation addItemToCart {

The code above should resolve to something similar to this:

```js
```jsonc
// Response
{
"data": {
Expand Down
Loading

0 comments on commit bda8566

Please sign in to comment.