title: How can we Convert JsonWriter To JsonObject in GSON
body: <p>Can someone guide me how to convert JsonWriter to JsonObject in GSON without any predefined object.</p>
  
  <pre><code>JsonWriter  writer = new JsonWriter(new FileWriter("C:\\Users\\ravr\\Desktop\\outputJSONSChema.json"));
          writer.setIndent( "    " );
          writer.beginObject();
          writer.name( "$schema" ).value( "http://json-schema.org/draft-04/schema#" );
          writer.name( "type" ).value( "object" );
              writer.name("properties");
                  writer.beginObject();//1Properties START
                      writer.name( "Country" );
                          writer.beginObject();//2EMP START
                              writer.name( "type" ).value( "array" );
                              writer.name( "minItems" ).value(0);
                              writer.name( "maxItems" ).value("undefined");
                              writer.name( "items" );
                                  writer.beginObject();//3 EMP ITEM START
                                      writer.name( "type" ).value( "object" );
                                      writer.name( "properties" );
                                          writer.beginObject();// 
  
                                              writer.name( "ID" );
                                                  writer.beginObject();// 5 EMP ID START
                                                      writer.name( "type" ).value( "String" );
                                                  writer.endObject(); // 5 EMP ID END
  
                                              writer.name( "NAME" );
                                                  writer.beginObject();// 5 EMP ID START
                                                      writer.name( "type" ).value( "String" );
                                                  writer.endObject(); // 5 EMP ID END
                                          writer.endObject();
                                  writer.endObject();//3 EMP ITEM END
                              writer.name( "required" );
                              writer.beginArray();
                                  writer.value( "ID" );
                                  writer.value( "NAME" );
                              writer.endArray();
                          writer.endObject();//2EMP END
                  writer.endObject();//1Properties END
          writer.endObject();
          writer.flush();
  </code></pre>