Split a string and get only value

hi i need to get only value i.e Basic xxxxxxxxxxxxxxxxxx= from this below json which is converted to string
[{“action”:“get”,“node”:{“key”:"/ridEnvToken",“value”:“Basic xxxxxxxxxxxxxxxxxx=”,“modifiedIndex”:45,“createdIndex”:45}}

Hi @mrk,

package main

import (

type MYTYPE struct {
   Action string `json:"action"`
   Node   struct {
   	Key           string `json:"key"`
   	Value         string `json:"value"`
   	ModifiedIndex int    `json:"modifiedIndex"`
   	CreatedIndex  int    `json:"createdIndex"`
   } `json:"node"`

func main() {
   str := `{"action":"get","node":{"key":"/ridEnvToken","value":"Basic xxxxxxxxxxxxxxxxxx=","modifiedIndex":45,"createdIndex":45}}`
   res := MYTYPE {}
   json.Unmarshal([]byte(str), &res)


Basic xxxxxxxxxxxxxxxxxx=

Program exited.

Code: https://play.golang.org/p/p0XAHa9Ena5

Is this what you are looking for?

1 Like

Or just: https://play.golang.org/p/w64FsF1Tmdm

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.