Results 1 to 15 of 15
  1. #1
    America's Avatar
    Join Date
    Oct 2014
    Gender
    male
    Location
    The greatest country on earth
    Posts
    79
    Reputation
    10
    Thanks
    24
    My Mood
    Lurking

    Thumbs up Opening and adding text to a json file

    Hello! I needed help opening and added text to a json file, as you know, json files are not regular text files, so I need some way to find a spot inside of the json file, and add the code according to the file structure, please help!

  2. #2
    AQWSeller69's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Posts
    6
    Reputation
    10
    Thanks
    0
    My Mood
    Twisted
    I also had this problem when I needed to make a minecraft server on windows 8. I had no problems on my mac since it opened as a text file, but here's what I figured out and worked for me:
    1. Make the .json file a text file by adding .txt at the end of it. (rename)
    2. Open it using notepad or whatever textedit program you have.
    3. Do all changes you want.
    4. Save your changes and close the program.
    5. Make it back to json by adding .json (rename once again)
    6. Done!

  3. #3
    Mayion's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Location
    Bed
    Posts
    13,504
    Reputation
    4018
    Thanks
    8,373
    My Mood
    Twisted
    You should be able to read/write to it normally like any type of text file.
    Last edited by Mayion; 05-18-2015 at 03:30 AM.
    I do not use any type of messenger outside of MPGH.
    Inactive but you can reach me through VM/PM.










     

    Donator - 30 August 2013
    Battlefield Minion - 26 October 2013

    Blackshot Minion - 14 January 2014/16 September 2014
    Minecraft Minion - 7 February 2014/16 September 2014
    WarRock Minion - 23 February 2014
    League of Legends Minion - 21 March 2014

    Minion+ - 15 May 2014
    Other Semi-Popular First Person Shooter Minion - 8 August 2014
    CrossFire Minion - 23 October 2014
    Programming Section Minion - 13 November 2014
    Marketplace Minion - 7 December 2014

    Official Middleman - 7 December 2014 - 27 June 2015
    Moderator - 29 December 2014
    Project Blackout Minion - 10 January 2015
    News Force Interviewer - January 2015
    Steam Games Minion - 21 March 2015
    Dragon Nest Minion - 31 March 2015
    Publicist - April 2015 - 21 September 2015
    Global Moderator - 25 August 2015
    Super User - 13 August 2016



  4. #4
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Quote Originally Posted by eplays View Post
    Hello! I needed help opening and added text to a json file, as you know, json files are not regular text files, so I need some way to find a spot inside of the json file, and add the code according to the file structure, please help!
    You could try and IO.File.ReadAllLines()
    And store that to an string array, if you know the line you want to add or edit some text you can just use:

    MyStringArray(5) = "This is my line!"

    This would edit the text on line 5. OFC you need to write it back

    IO.File.WriteAllLines(MyStringArray)

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  5. #5
    Raydenman's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Location
    Italy
    Posts
    261
    Reputation
    10
    Thanks
    811
    My Mood
    Amused
    Quote Originally Posted by Mayion View Post
    You should be able to read/write to it normally like any type of text file.
    Are you sure bro?

    Quote Originally Posted by Jorndel View Post


    You could try and IO.File.ReadAllLines()
    And store that to an string array, if you know the line you want to add or edit some text you can just use:

    MyStringArray(5) = "This is my line!"

    This would edit the text on line 5. OFC you need to write it back

    IO.File.WriteAllLines(MyStringArray)
    You let laugh, go away please.

    @eplays use a stream or serialize and deserialize it

  6. #6
    Mayion's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Location
    Bed
    Posts
    13,504
    Reputation
    4018
    Thanks
    8,373
    My Mood
    Twisted
    Quote Originally Posted by Raydenman View Post
    Are you sure bro?



    You let laugh, go away please.

    @eplays use a stream or serialize and deserialize it

    k
    I do not use any type of messenger outside of MPGH.
    Inactive but you can reach me through VM/PM.










     

    Donator - 30 August 2013
    Battlefield Minion - 26 October 2013

    Blackshot Minion - 14 January 2014/16 September 2014
    Minecraft Minion - 7 February 2014/16 September 2014
    WarRock Minion - 23 February 2014
    League of Legends Minion - 21 March 2014

    Minion+ - 15 May 2014
    Other Semi-Popular First Person Shooter Minion - 8 August 2014
    CrossFire Minion - 23 October 2014
    Programming Section Minion - 13 November 2014
    Marketplace Minion - 7 December 2014

    Official Middleman - 7 December 2014 - 27 June 2015
    Moderator - 29 December 2014
    Project Blackout Minion - 10 January 2015
    News Force Interviewer - January 2015
    Steam Games Minion - 21 March 2015
    Dragon Nest Minion - 31 March 2015
    Publicist - April 2015 - 21 September 2015
    Global Moderator - 25 August 2015
    Super User - 13 August 2016



  7. #7
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Quote Originally Posted by Raydenman View Post
    Maybe you didn't understand you are useless.
    You're not even the one asking for help.
    Atleast I gave code examples and informed the user about one possible way. No need to be rude like this, no one likes that

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  8. The Following User Says Thank You to Jorndel For This Useful Post:

    TonyMane() (07-22-2015)

  9. #8
    Raydenman's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Location
    Italy
    Posts
    261
    Reputation
    10
    Thanks
    811
    My Mood
    Amused
    Quote Originally Posted by Mayion View Post



    k
    Ok bro you understood all.
    Ok. [sarcasm]
    Last edited by Raydenman; 05-19-2015 at 07:14 AM.

  10. #9

  11. #10
    America's Avatar
    Join Date
    Oct 2014
    Gender
    male
    Location
    The greatest country on earth
    Posts
    79
    Reputation
    10
    Thanks
    24
    My Mood
    Lurking
    That is very useful info, thank you so much, I will defintly try that way.

  12. #11
    Raydenman's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Location
    Italy
    Posts
    261
    Reputation
    10
    Thanks
    811
    My Mood
    Amused
    Quote Originally Posted by eplays View Post
    That is very useful info, thank you so much, I will defintly try that way.
    Don't read that, you must serialize/deserialize a JSON file, btw is it hosted?
    @Mayion

  13. #12
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Statically typed languages such as VB.NET aren't particularly well-suited for dealing with dynamic data structures like JSON. If you have the option you'd be better off using a dynamically-typed language such as Python, PHP...etc. as they have robust built-in ways of dealing with JSON data.

    However, you do have options with VB.NET. If you're targetting .NET Framework 4.0 (not Client Profile) then you can add a reference "System.Web.Extensions" in your project and utilize the JavaScriptSerializer class.

    A really basic example:
    Code:
    Imports System.Web.Script.Serialization
    
    ' ...snip
    
            Dim json As String = IO.File.ReadAllText("B:\test.json")
            Dim serializer As New JavaScriptSerializer()
    
            Dim jsonObj = serializer.DeserializeObject(json)
            ' You can now use the array-access notation to extract values from the json Object
            MessageBox.Show(jsonObj("example").ToString())
    
            ' To add new values you can again use array notation:
            jsonObj("new-key") = "Some Value"
    
            ' And write it back out to disk:
            IO.File.WriteAllText("B:\test.json", serializer.Serialize(jsonObj))

    Before I can give you much more info though, what is the format of your JSON file? Is it going to be the same format every time or does it change a lot? If you post a copy of it here I can give you a more concrete example of how to proceed.
    Last edited by Jason; 05-29-2015 at 10:07 PM.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  14. The Following User Says Thank You to Jason For This Useful Post:

    [MPGH]Mayion (06-26-2015)

  15. #13
    America's Avatar
    Join Date
    Oct 2014
    Gender
    male
    Location
    The greatest country on earth
    Posts
    79
    Reputation
    10
    Thanks
    24
    My Mood
    Lurking
    Here is the format

    Code:
    {
      "profiles": {
        "PROFILENAMEHERE": {
          "name": "PROFILENAME"
        }
      },
      "selectedProfile": "PROFILENAME",
      "clientToken": "clientTokenHere",
      "authenticationDatabase": {
        "authenticationDatabase Here": {
          "displayName": "DynamicGaming1",
          "userProperties": [
            {
              "name": "twitch_access_token",
              "value": "twitchaccesstokenHere"
            }
          ],
          "accessToken": "Access Token",
          "userid": "userIDhere",
          "uuid": "uuidHere",
          "username": "Usersnames email address here"
        }
      },
      "selectedUser": "selectedUser (token probably, I suck at coding)",
      "launcherVersion": {
        "name": "1.6.11",
        "format": 17
      }
    }
    I am a huge noob, so please don't be harsh.
    Last edited by Mayion; 06-26-2015 at 03:42 PM.

  16. #14
    Mayion's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Location
    Bed
    Posts
    13,504
    Reputation
    4018
    Thanks
    8,373
    My Mood
    Twisted
    Quote Originally Posted by eplays View Post
    Here is the format
    What are you trying to do?
    I do not use any type of messenger outside of MPGH.
    Inactive but you can reach me through VM/PM.










     

    Donator - 30 August 2013
    Battlefield Minion - 26 October 2013

    Blackshot Minion - 14 January 2014/16 September 2014
    Minecraft Minion - 7 February 2014/16 September 2014
    WarRock Minion - 23 February 2014
    League of Legends Minion - 21 March 2014

    Minion+ - 15 May 2014
    Other Semi-Popular First Person Shooter Minion - 8 August 2014
    CrossFire Minion - 23 October 2014
    Programming Section Minion - 13 November 2014
    Marketplace Minion - 7 December 2014

    Official Middleman - 7 December 2014 - 27 June 2015
    Moderator - 29 December 2014
    Project Blackout Minion - 10 January 2015
    News Force Interviewer - January 2015
    Steam Games Minion - 21 March 2015
    Dragon Nest Minion - 31 March 2015
    Publicist - April 2015 - 21 September 2015
    Global Moderator - 25 August 2015
    Super User - 13 August 2016



  17. #15
    America's Avatar
    Join Date
    Oct 2014
    Gender
    male
    Location
    The greatest country on earth
    Posts
    79
    Reputation
    10
    Thanks
    24
    My Mood
    Lurking
    Quote Originally Posted by Mayion View Post

    What are you trying to do?
    You see, I have a program that installs hack clients automatically for minecraft, but it is very bland and simple, not to useful to many. So what I wanted to do, is when you click install, it installs the client, then it somehow opens a json file, and adds all the properties accordingly to the json structure. I don't know java so it is very confusing to me.

Similar Threads

  1. How to open and edit CFT file?
    By Viper1993 in forum Crossfire Coding Help & Discussion
    Replies: 2
    Last Post: 08-23-2014, 11:04 AM
  2. [Help] How To Open and Edit UT2 file?
    By wongjeffry in forum Coders Lounge
    Replies: 5
    Last Post: 12-06-2013, 07:31 AM
  3. newbs and ads
    By dk173 in forum General
    Replies: 15
    Last Post: 03-11-2009, 04:58 AM
  4. Rustynail and Velruf TEXT
    By _gamer21_ in forum WarRock - International Hacks
    Replies: 6
    Last Post: 07-01-2008, 09:43 AM
  5. favrent anime opening and ending(music)
    By Doupleganger in forum Anime
    Replies: 3
    Last Post: 07-25-2007, 06:29 AM