title: Generate a json by formatting the return value of a method to json
body: <p>I want to generate a json by formatting the return value of a method to json. </p>
  
  <p>Here is the format for the json:</p>
  
  <pre><code>{
    "Users": [
    {
      "Id1" : user.Id1,
      "Id2" : user.Id2
    },
    {
      "Id1" : user.Id1,
      "Id2" : user.Id2
    }]
  }
  </code></pre>
  
  <p>The Method that should return JToken:</p>
  
  <pre><code>public static JToken SaveUsers(User user)
  {
       context.asp_User_Update(user.Id1, user.Id2 //omitted some arguments);
       return user.Id1 + user.Id2;
  }
  </code></pre>
  
  <p>I want this method whatever ids it will return to generate a json similar to the format I was given above.</p>
  
  <p>I tried this code:</p>
  
  <pre><code>JToken json = JObject(
                         JProperty("Users", new JArray(new JObject (new
                         JProperty("Id1", user.Id1), 
                         JProperty("Id2", user.Id2))))
                       );
  </code></pre>
  
  <p>I know I need to use a loop to dynamical generate the JProperty for the <code>user.Id1</code> and <code>user.Id2</code>.</p>