C3 Data Convert Example

4

Index

Stats

2,701 visits, 5,743 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 27 Dec, 2023. Last updated 11 Sep, 2024

How to Use JSON

Example 1

{
  "name": "Love"
}
JSON.Get("name")  // Love

Example 1.2

{
  "name": "Love",
  "amount": 100,
}
JSON.Get("amount")  // 100

Example 1.3

{
	"data": {
		"name": "Love",
		"amount": 100
	}
}
JSON.Get("data.name") // Love

Example 1.4

{
	"store": {
		"name": "Love",
		"level": 100,
		"info": {
			"title": "Love Store",
			"location": "Lover Pond"
		}
	}
}
JSON.Get("store.info.location") // Lover's Pond

Example 2 (Array)

{
  "data": [123, 456]
}
JSON.Get("data.0")  // 123
JSON.Get("data.1")  // 456

Example 2.2

{
  "items": ["apple", "banana"]
}
JSON.Get("items.0")  // apple
JSON.Get("items.1")  // banana

Example 2.3

{
  "name": "Love",
  "data": [123, 456]
  "items": ["apple", "banana"]
}
JSON.Get("name")	// Love
JSON.Get("data.0")	// 123
JSON.Get("items.1")	// banana

Example 2.4

{
	"data": {
		"name": "Love",
		"items": [
			"apple",
			"banana"
		]
	},
}
JSON.Get("data.name")		// Love
JSON.Get("data.items.0")	// apple
JSON.Get("data.items.1")	// banana

Example 2.5

{
	"items": [
		{
			"name": "apple",
			"amount": 2
		},
		{
			"name": "banana",
			"amount": 6
		}
	]
}
JSON.Get("items.0.name")	// apple
JSON.Get("items.1.name")	// banana
JSON.Get("items.0.amount")	// 2
JSON.Get("items.1.amount")	// 6
  • 0 Comments

Want to leave a comment? Login or Register an account!