Simulation Core
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

59 行
2.2 KiB

  1. # 1 "/mnt/c/Projects/VSIM/SimulationCore2/Test/testJson.f90"
  2. program testjson
  3. use json_module
  4. use RedisInterface
  5. use iso_c_binding, only: c_null_char,c_char
  6. integer::n_children
  7. logical :: is_found
  8. character(len=100),allocatable::redisOutput
  9. type(json_file) :: jsonfile
  10. type(json_value),pointer :: jsonroot,pval
  11. type(json_core) :: json
  12. character(len=:),allocatable::name
  13. integer::simulationStatus,simulationSpeed
  14. ! call initConnection("config-remote.json")
  15. ! call getData(redisContent)
  16. ! print *,len(redisContent)," bytes read from redis"
  17. ! open(1,file="redisContent.json",status="REPLACE")
  18. ! write(1,"(A)") redisContent
  19. ! close(1)
  20. ! call jsoncore%initialize()
  21. ! call jsoncore%deserialize(jsonvalue,redisContent)
  22. redisOutput = '{"status":1,"speed":10}'
  23. print *,"redisOutput=",redisOutput
  24. call jsonfile%initialize()
  25. call jsonfile%deserialize(redisOutput)
  26. ! call jsonfile%get("speed",simulationSpeed,is_found)
  27. ! if ( .not. is_found ) print *,"speed Not Found"
  28. ! call jsonfile%get("status",simulationStatus,is_found)
  29. ! if ( .not. is_found ) print *,"status Not Found"
  30. ! call jsonfile%get(pval,simulationSpeed)
  31. print *,"speed=",simulationSpeed
  32. print *,"status=",simulationStatus
  33. call jsonfile%json_file_get_root(jsonroot)
  34. call json%get(jsonroot,'status',pval)
  35. call json%get(pval,simulationStatus)
  36. call json%get(jsonroot,'speed',pval)
  37. call json%get(pval,simulationSpeed)
  38. print *,"speed=",simulationSpeed
  39. print *,"status=",simulationStatus
  40. call json%destroy(jsonroot)
  41. ! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
  42. ! call jsonfile%json_file_get_root(jsonvalue)
  43. ! call jsoncore%info(jsonvalue, n_children=n_children)
  44. ! print *,"n_children =",n_children
  45. ! call jsoncore%info(jsonvalue, name=name)
  46. ! print *,"name = ",name
  47. ! call json%initialize(allow_duplicate_keys=.false.)
  48. ! call json%create_object(p,'') !create the root
  49. ! call json%add(p,'year',1805) !add some data
  50. ! call json%add(p,'year',2000) !add some data
  51. ! call json%add(p,'value',1.0) !add some data
  52. ! call json%print(p,'test.json') !write it to a file
  53. ! call json%destroy(p) !cleanup
  54. end program testjson