1

I need to create a js file from Java as shown below as fileList.js

var userList = [
{
    "Name":"Name_1",
    "Age":"20",
    "Mark":"22%"
},
{
    "Name":"Name_2",
    "Age":"23",
    "Mark":"45%"

},
{
    "Name":"Name_3",
    "Age":"22",
    "Mark":"43%"
},
{
    "Name":"Name_4",
    "Age":"27",
    "Mark":"52%"
}];

Is it possible to create by simplejson api? Please help me on this.

Fayis K
  • 61
  • 7
  • 1
    You need to create a new instance for each item. Meaning before 'jObj.put("Name", "Name_2");' add 'JSONObject jObj = new JSONObject();', the same goes for 'jObj.put("Name", "Name_3");' – Tzach Solomon Oct 19 '16 at 12:58
  • Here issue is not similar to [link](http://stackoverflow.com/questions/19843506/why-does-my-arraylist-contain-n-copies-of-the-last-item-added-to-the-list). I want create a js file with JSON array by Java – Fayis K Oct 20 '16 at 10:19
  • 1
    Thanks Tzach Solomon. It is working.. :) – Fayis K Oct 20 '16 at 10:22

0 Answers0