Jump to content

[1.7.10] [Solved] Json troubles. :/


Recommended Posts

Posted

I have hit a minor roadblock in my mod. I'm usually pretty good with using Gson but I'm having problems. I would like to know how to have names and values as a value for a name. This probably sounds REALLY confusing so I'll explain.

 

I want to something similar to minecrafts mcmeta files. In some, there is an animation:

{
    "animation":{}
}

 

And some blocks/items have values inside that animation:

{
  "animation": {
    "frames": [
      16,
      17,
      18,
      19,
      20,
      21,
      22,
      23,
      24,
      25,
      26,
      27,
      28,
      29,
      30,
      31,
      0,
      1,
      2,
      3,
      4,
      5,
      6,
      7,
      8,
      9,
      10,
      11,
      12,
      13,
      14,
      15
    ]
  }
}

 

That is what I want to do. If you aren't really confused by this, how would I do that? If you are confused, tell me, I might be able to explain this better. :)

Posted

Ok, I think that answers my question. So if I'm understanding this correctly, I would do something like this?

JsonWriter json = new JsonWriter(new FileWriter(file));
json.beginObject();

json.name("example");
json.beginObject();

json.name("exampleString").value("value");

json.endObject();

json.endObject();

json.close();

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.