好像跟題目要得差點點但我不知道哪裡錯(訊息太長省略),請幫幫我看一下😰
謝謝~
#include<bits/stdc++.h>
using namespace std;
int main(){
string str;
string key;
string value;
cout << "{";
int p = 0;
while(cin>>str){
if(str == "insert"){
cin>>key>>value;
if(value != "newJSONObject"){
if(p!=0){
cout << ",";
}
cout << key << ":"<< value;
p++;
}else{
cout <<","<< key << ":{";
p=0;
}
}else if(str == "end"){
cout << "}";
}
}
}