@@ -106,62 +106,57 @@ std::string Board::GetJson() {
106
106
}
107
107
}
108
108
*/
109
- std::string json = " {" ;
110
- json += " \" version\" :2," ;
111
- json += " \" language\" :\" " + std::string (Lang::CODE) + " \" ," ;
112
- json += " \" flash_size\" :" + std::to_string (SystemInfo::GetFlashSize ()) + " ," ;
113
- json += " \" minimum_free_heap_size\" :" + std::to_string (SystemInfo::GetMinimumFreeHeapSize ()) + " ," ;
114
- json += " \" mac_address\" :\" " + SystemInfo::GetMacAddress () + " \" ," ;
115
- json += " \" uuid\" :\" " + uuid_ + " \" ," ;
116
- json += " \" chip_model_name\" :\" " + SystemInfo::GetChipModelName () + " \" ," ;
117
- json += " \" chip_info\" :{" ;
109
+ std::string json = R"( {"version":2,"language":")" + std::string (Lang::CODE) + R"( ",)" ;
110
+ json += R"( "flash_size":)" + std::to_string (SystemInfo::GetFlashSize ()) + R"( ,)" ;
111
+ json += R"( "minimum_free_heap_size":")" + std::to_string (SystemInfo::GetMinimumFreeHeapSize ()) + R"( ",)" ;
112
+ json += R"( "mac_address":")" + SystemInfo::GetMacAddress () + R"( ",)" ;
113
+ json += R"( "uuid":")" + uuid_ + R"( ",)" ;
114
+ json += R"( "chip_model_name":")" + SystemInfo::GetChipModelName () + R"( ",)" ;
118
115
119
116
esp_chip_info_t chip_info;
120
117
esp_chip_info (&chip_info);
121
- json += " \" model \" : " + std::to_string (chip_info. model ) + " , " ;
122
- json += " \" cores \" : " + std::to_string (chip_info.cores ) + " , " ;
123
- json += " \" revision \" : " + std::to_string (chip_info.revision ) + " , " ;
124
- json += " \" features \" : " + std::to_string (chip_info.features ) ;
125
- json += " }, " ;
118
+ json += R"( "chip_info":{ ) " ;
119
+ json += R"( "model": ) " + std::to_string (chip_info.model ) + R"( , ) " ;
120
+ json += R"( "cores": ) " + std::to_string (chip_info.cores ) + R"( , ) " ;
121
+ json += R"( "revision": ) " + std::to_string (chip_info.revision ) + R"( , )" ;
122
+ json += R"( "features": )" + std::to_string (chip_info. features ) + R"( }, ) " ;
126
123
127
- json += " \" application\" :{" ;
128
124
auto app_desc = esp_app_get_description ();
129
- json += " \" name \" : \" " + std::string (app_desc-> project_name ) + " \" , " ;
130
- json += " \" version \" : \" " + std::string (app_desc->version ) + " \" , " ;
131
- json += " \" compile_time \" : \" " + std::string (app_desc->date ) + " T " + std::string (app_desc-> time ) + " Z \" , " ;
132
- json += " \" idf_version \" : \" " + std::string (app_desc->idf_ver ) + " \" , " ;
133
-
125
+ json += R"( "application":{ ) " ;
126
+ json += R"( "name":" ) " + std::string (app_desc->project_name ) + R"( ", ) " ;
127
+ json += R"( "version":" ) " + std::string (app_desc->version ) + R"( ", ) " ;
128
+ json += R"( "compile_time":" ) " + std::string (app_desc->date ) + R"( T )" + std::string (app_desc-> time ) + R"( Z", ) " ;
129
+ json += R"( "idf_version":" )" + std::string (app_desc-> idf_ver ) + R"( ", )" ;
134
130
char sha256_str[65 ];
135
131
for (int i = 0 ; i < 32 ; i++) {
136
132
snprintf (sha256_str + i * 2 , sizeof (sha256_str) - i * 2 , " %02x" , app_desc->app_elf_sha256 [i]);
137
133
}
138
- json += " \ " elf_sha256\" : \" " + std::string (sha256_str) + " \" " ;
139
- json += " }, " ;
134
+ json += R"( "elf_sha256":" ) " + std::string (sha256_str) + R"( " ) " ;
135
+ json += R"( }, ) " ;
140
136
141
- json += " \ " partition_table\ " : [" ;
137
+ json += R"( "partition_table": [) " ;
142
138
esp_partition_iterator_t it = esp_partition_find (ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL );
143
139
while (it) {
144
140
const esp_partition_t *partition = esp_partition_get (it);
145
- json += " {" ;
146
- json += " \" label\" :\" " + std::string (partition->label ) + " \" ," ;
147
- json += " \" type\" :" + std::to_string (partition->type ) + " ," ;
148
- json += " \" subtype\" :" + std::to_string (partition->subtype ) + " ," ;
149
- json += " \" address\" :" + std::to_string (partition->address ) + " ," ;
150
- json += " \" size\" :" + std::to_string (partition->size );
151
- json += " }," ;
141
+ json += R"( {)" ;
142
+ json += R"( "label":")" + std::string (partition->label ) + R"( ",)" ;
143
+ json += R"( "type":)" + std::to_string (partition->type ) + R"( ,)" ;
144
+ json += R"( "subtype":)" + std::to_string (partition->subtype ) + R"( ,)" ;
145
+ json += R"( "address":)" + std::to_string (partition->address ) + R"( ,)" ;
146
+ json += R"( "size":)" + std::to_string (partition->size ) + R"( },)" ;;
152
147
it = esp_partition_next (it);
153
148
}
154
149
json.pop_back (); // Remove the last comma
155
- json += " ], " ;
150
+ json += R"( ], ) " ;
156
151
157
- json += " \ " ota\ " :{" ;
152
+ json += R"( "ota":{) " ;
158
153
auto ota_partition = esp_ota_get_running_partition ();
159
- json += " \ " label\" : \" " + std::string (ota_partition->label ) + " \" " ;
160
- json += " }, " ;
154
+ json += R"( "label":" ) " + std::string (ota_partition->label ) + R"( " ) " ;
155
+ json += R"( }, ) " ;
161
156
162
- json += " \ " board\" : " + GetBoardJson ();
157
+ json += R"( "board": ) " + GetBoardJson ();
163
158
164
159
// Close the JSON object
165
- json += " } " ;
160
+ json += R"( } ) " ;
166
161
return json;
167
162
}
0 commit comments