Community
    • Login

    Help for a JSON formatting.

    Scheduled Pinned Locked Moved General Discussion
    4 Posts 4 Posters 1.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Raja AdikusumaR
      Raja Adikusuma
      last edited by

      I’m a newbie, like almost zero experience in anything like coding, programming etc.
      I got a JSON file, Live2D json from a web game to be exact .

      Snippet.
      [1,0,0,[["cc.JsonAsset",["_name","json"],1]],[[0,0,1,3]],[[0,"HJhuiyeji.model3",{"Version":3,"FileReferences":{"Moc":"HJhuiyeji.moc3","Physics":"HJhuiyeji.physics3.json","DisplayInfo":"HJhuiyeji.cdi3.json","Textures":["HJhuiyeji.2048/HJhuiyeji.png"
      

      That’s the snippet of the json. When I researched Live2D json format(by looking at some example)

      The example
      {
        "Version": 3,
        "FileReferences": {
          "Moc": "huajia_zhugeliang01.moc3",
          "Textures": [
            "textures/texture_00.png",
            "textures/texture_01.png"
      

      That’s how the format should be. So I tried and found the JSON Viewer plugin to format the snippet json, and it became like this.

      [
      	1,
      	0,
      	0,
      	[
      		[
      			"cc.JsonAsset",
      			[
      				"_name",
      				"json"
      			],
      			1
      		]
      	],
      	[
      		[
      			0,
      			0,
      			1,
      			3
      		]
      	],
      	[
      		[
      			0,
      			"HJhuiyeji.model3",
      			{
      				"Version": 3,
      				"FileReferences": {
      					"Moc": "HJhuiyeji.moc3",
      					"Physics": "HJhuiyeji.physics3.json",
      					"DisplayInfo": "HJhuiyeji.cdi3.json",
      					"Textures": [
      						"HJhuiyeji.2048/HJhuiyeji.png"
      

      As you can see it gets formatted, but it can’t be read by live2d program unless I remove unnecessary part, that is like everything before “Version”: 3,
      So how do I remove these parts and turn it like The Example, which doesn’t have that many white spaces so it can be read by the program.
      If anyone can help, I’d be happy.
      Note: If this question violate notepad++ rules or etc, let me know I’ll delete it.

      1 Reply Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson
        last edited by

        Ordinarily I would recommend JsonTools for this sort of task, but your JSON is a real mess, with arrays that contain a confused jumble of different types, so JsonTools is less useful than it might otherwise be. Likely whatever suggestion I give will only work in this specific situation.

        That said, if you open the JsonTools tree view and execute the RemesPath query @[5][0][2][Version, FileReferences], then click the Save query result button, that would print the JSON you want in a new buffer.

        There’s lots of RemesPath documentation in the GitHub repo linked above. PythonScript is also a reasonable option for this sort of problem.

        1 Reply Last reply Reply Quote 3
        • Mudassir RazaM
          Mudassir Raza
          last edited by PeterJones

          That JSON snippet looks fine — it’s just not indented properly, so it’s hard to read.
          You can format JSON in a few ways:

          1. In Notepad++, install the JSON Viewer plugin (as you already did).
          2. Or, if you just want something quick in the browser, try a free online JSON viewer — it shows tree view and highlights errors instantly.
            I personally use JSONAce . com
            — it’s browser-only (no uploads) and formats + minifies JSON nicely.
            Once you pretty-print it, you’ll easily see where the missing commas or braces are.

          –
          moderator: delinkified

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Mudassir Raza
            last edited by PeterJones

            @Mudassir-Raza said in Help for a JSON formatting.:

            That JSON snippet looks fine — it’s just not indented properly, so it’s hard to read.

            And has syntax errors, since there are four arrays and two objects which are not properly terminated.

            You can format JSON in a few ways:

            1. In Notepad++, install the JSON Viewer plugin (as you already did).

            Or the JsonTools plugin mentioned above. I tried both on the original data: JSON Viewer refused to format it, because of the syntax errors. JsonTools warned about the syntax errors, but then made its best guess to close off the arrays and objects and then formatted it.

            1. Or, if you just want something quick in the browser, try a free online JSON viewer — it shows tree view and highlights errors instantly.

            This is a Notepad++ forum. Unless Notepad++ has no way of doing it, and especially for first-time posters, it is frowned upon suggesting external tools. And since both JSON Viewer and JsonTools can help with that messy data, to some extent, there is no reason to advertise external tools – they both have error detection, they both have pretty-printers, and they both have tree-view panels available, which covers all the features you mentioned of the website, so I can see no good reason to bring up that site.

            Given that the conversation was a year old, and the only new information you added was the advertisement for an external website, I was tempted to ban you as a spammer. And since I’m still not convinced that website traffic isn’t the only reason you posted, I am de-linkifying your post. Anyone who is curious about the site you’ve advertised will still be able to figure out where it is, but it will prevent automatic crawlers from wasting site bandwidth here as a redirect to the site you advertised.

            1 Reply Last reply Reply Quote 1
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors