tencent cloud

All product documents
Tencent Cloud Super App as a Service
JSON Configuration
Last updated: 2024-11-21 18:28:34
JSON Configuration
Last updated: 2024-11-21 18:28:34
JSON is a data format, not a programming language. For mini programs, JSON plays the role of static configuration.

Example

Let's start by looking at an example. Please find the app.json file in the root directory and open it in the code editor. And the app.json file code for this document is as follows:
{
"pages":[
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
}
}
Change the value of "navigationBarTitleText" in line 9 from WeChat to MiniProgram.

Save the file and upon automatic IDE refresh, you can see that the title at the top of emulator has changed from WeChat to MiniProgram.

JSON files are used for static configuration in mini program development and determine some mini program performance before it runs. Please note that the mini program cannot dynamically update the JSON configuration file during the running process in order to make corresponding changes.

JSON syntax

Compared with XML file, JSON file is a lightweight data exchange format, as it usually doesn't require specialized tools for reading or modifying.
JSON file code is wrapped in curly brackets {} and the data is in a key-value format.

It looks like JavaScript's object expression, but it's different.
The keys in JSON file must be double-quoted strings. Common mistakes include forgetting to enclose the keys in double quotes or mistakenly enclose them in single quotes.

The value of the key-value pairs in JSON file can be any of the following types:
1. Number, including floating-point numbers and integers.
2. String that enclosed in double quotes.
3. Boolean, true or false.
4. Array that enclosed in square brackets [].
5. Object that enclosed in curly brackets {}.
6. Null.
Other value types will trigger an error, for example, in JavaScript.

Note that no comments are allowed in JSON data, otherwise, an error will occur.


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon