Meenakshi Agarwal

Meenakshi Agarwal

  • 1.2k
  • 130
  • 21.7k

How to keep C code in a JSON file and parse from Angular?

Oct 13 2018 5:45 AM
I would like to keep a multi-line C code inside a JSON file something like shown in the below coding snippet. 
  1. [  
  2.     {  
  3.         language: "C",  
  4.         value: "int c = 0;   
  5. for (int i=0; i < 10; ++i) {  
  6. }  
  7. printf("Hello Angular");  
  8. "  
  9.     },  
  10.     {  
  11.         language: "C++",  
  12.         value: "int main() {  
  13. char* str= new char[10];}"  
  14.     }  
  15. ]  
However, the Angular fails to load and parse the above JSON file. It seems like conflicting due to the curly braces and the new line characters. Any help in resolving this issue is much appreciated.

Answers (3)