megajson | JSON parser generator for high performance | JSON Processing library
kandi X-RAY | megajson Summary
kandi X-RAY | megajson Summary
Go's builtin JSON support works great to provide simple, runtime JSON encoding and decoding. However, it's based on reflection so it has a few drawbacks:. Megajson is built to get around some of these limitations. It's a code generation tool that uses the go/parser and go/ast packages to write custom encoders and decoders for your types. These encoders and decoders know your types so the reflection package is not necessary.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of megajson
megajson Key Features
megajson Examples and Code Snippets
Community Discussions
Trending Discussions on megajson
QUESTION
I am having a bit of an issue. So I am writing a tool in go that works with some json files. The way the tool works is the devops member who is using it is supposed to upload their json file into the specified folder within the project and then that json file is used from there to deploy an api in api-gateway (the json is actually a swagger with extensions but that isn't particularly important to my question)
The issue I am having is I need to update ONE line in the json. Each file passed in will be different, but it is guaranteed to have a url in the same spot every time, just due to the nature of the project. I need to update this url in an automated fashion.
Due to the fact the json files are different, setting up hard coded structs and unmarshalling in order to edit is out of the question. The objective is for the devops members to not even have to go into the code, but rather just to deploy their files, which is the reason I was hoping for this to be automated.
So far my research has yielded nothing. It appears that Go only supports editing json if it is first unmarshaled into structs (see Modifying JSON file using Golang). Is there a way to edit without the structs if i know for a fact what I am looking for will always be available within the json, despite each file being different?
This is only my first month using go, so there may be a simple solution. I have seen some mention of scanners from the megajson library, but I cannot seem to get that to work either
...ANSWER
Answered 2018-Jul-11 at 21:11One way you can solve this is by reading the file and changing it.
Lets say you have the file as you mentioned:
example.json
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install megajson
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page